Ajax Load More or View More functionality for woocommerce category layout by template overriding

You can achieve this by create a template override for woocommerce category layout. How to Create Template override Go to wp-content/theme/{your_theme} Create a folder named woocommerce if already not exist Then create a file titled archive-product.php Now, paste the below code as instructed and modify any parameters per your need Add this code right after … Read more

post__in not recognizing multiple IDs

This is more of a PHP than a WordPress issue: If $newstring = ‘15,30’; then array($newstring) is an array containing this string. If you print_r( array($newstring) ), it looks like this: Array ( [0] => 15,30 ) Which is not the same as array(15,30). What you want to do instead is: $newstring = ‘15,30’; $args … Read more

How much does $wpdb->prepare(), then $wpdb->query() VS straight $wpdb->query(), can slow down the load time of whole page

$wpdb->prepare shouldn’t make any significant difference. As you can see here (https://developer.wordpress.org/reference/classes/wpdb/prepare/#source), it doesn’t do much. It’s just taking care of proper escaping and formatting variables, so the final query is safe to run. So if you’re asking if there is a big difference between $wpdb->query( $wpdb->prepare( … ) ) and $wpdb->query( <SAFE_SQL> ), then … Read more

How to Delete Posts by title?

Like keepkalm said I’d find the list of post IDs from the database: select id, post_title FROM wp_posts where post_title like ‘%Pharmaton%’ or post_title like ‘%Winston Blu%’ or post_title like ‘%Kefir%’ or post_title like ‘%Tetradox%’ or post_title like ‘%Passport Sco%’; and then use the list of IDs with wp-cli’s wp post delete which accepts a … Read more

Pagination showing same posts despite changing page

After struggling for hours on this (and 6 years after the question was asked), for me the solution was lying within the $paged parameter: I changed $paged = ( get_query_var(‘paged’) ) ? get_query_var(‘paged’) : 1; to if ( get_query_var(‘paged’) ) { $paged = get_query_var(‘paged’); } else if ( get_query_var(‘page’) ) { $paged = get_query_var(‘page’); } … Read more

meta_query in wp_query not working as expected

It is not working because there is a custom query in the events plugin that adds the posts to be ignored (not returned) when you run WP_Query. See getHideFromUpcomingEvents() method in the-events-calendar/src/Tribe/Query.php. But there is however a filter hook that you can use there to do whatever. See the following sample code: function wpse283031_hide_ids( $ids … Read more

Wp query by 2 meta field – check if they exists / have value

Check the Codex. meta_query accepts an EXISTS comparison. $args = array( ‘post_type’ => ‘somepostype’, ‘meta_query’ => array( array( ‘key’ => ‘fname’.$userid, ‘compare’ => ‘EXISTS’, ), array( ‘key’ => ‘lname’.$userid, ‘compare’ => ‘EXISTS’, ) ) ); $query = new WP_Query( $args ); return $tempquery->found_posts; There is a note that… Note: Due to bug #23268, value is … Read more

wp_query->set for several categories

Try using tax_query: $tax_query = array( ‘relation’ => ‘AND’, array( ‘taxonomy’ => ‘category’, ‘field’ => ‘id’, ‘terms’ => 1 ), array( ‘taxonomy’ => ‘category’, ‘field’ => ‘id’, ‘terms’ => 2 ), array( ‘taxonomy’ => ‘category’, ‘field’ => ‘id’, ‘terms’ => 3 ) ); $query->set( ‘tax_query’, $tax_query );