0

I am trying to search woocommerce products from DB using wp_query, I have used pre_get_posts action to modify my main query.

add_action( 'pre_get_posts', 'custom_query_vars' );
 function custom_query_vars( $query ) {
  global $wpdb;

  if ( !is_admin() && $query->is_main_query()) {
if (is_search()) {
  $query->set( 'post_type', array('product', 'post', 'video', 'audio' ));
  $query->set( 'posts_per_page', 12 );
 }
}
}

it does fetch the correct products but the issue I am having is in $wp_query object it is returning me an unbelievable value for "found_posts" (9223372036854775807) and it stays the same for every search, also the same for "max_num_pages" (100). I am not getting why is it happening kindly if anyone can help me with it, Thanks in advance

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.