Friday, August 5, 2022
HomeWordPress Developmentwp question - $wp_query->found_posts not returning right worth

wp question – $wp_query->found_posts not returning right worth


I’m making an attempt to go looking woocommerce merchandise from DB utilizing wp_query,
I’ve used pre_get_posts motion to change my important question.

add_action( 'pre_get_posts', 'custom_query_vars' );
 operate custom_query_vars( $question ) {
  international $wpdb;

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

it does fetch the proper merchandise however the difficulty I’m having is in $wp_query object it’s returning me an unbelievable worth for “found_posts” (9223372036854775807) and it stays the identical for each search, additionally the identical for “max_num_pages” (100).
I’m not getting why is it occurring kindly if anybody may help me with it,
Thanks prematurely

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments