enter image description here

Here’s what I have in search.php file:

$category_blog = get_category_by_slug('blog');
$category_review = get_category_by_slug('review');
$paged = ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1;
$search_query = get_search_query();
$the_posts = new WP_Query(array(
  'category__in' => array( $category_blog->term_id,  $category_review->term_id),
  's' => $search_query,
  'paged' => $paged,
  'posts_per_page' => 10,
  'post_type' => 'post',

And you can check the output below:

It’s messing with the WordPress pagination since I got this in sql:

SELECT ...... wp_posts.post_date DESC LIMIT 0, 999999999'

When I remove 's' => $search_query, I would get the same posts_per_page under the two public properties:

I have no idea what’s going on here. Any suggest?

Read more here: Why WordPress WP_Query has different `posts_per_page` under public `query` and `query_vars`


If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Wordpress related questions and answers: