Seems like a simple thing, but I can't seem to understand what's happening.
I need to limit the number of posts to 25, but my wp_query always returns all of the records, and ignores the posts_per_page argument.
Here is my code:
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array(
'posts_per_page' => 25,
'paged' => $paged,
'post_type' => 'noo_company',
'industry' => $industry,
);
$the_query = new WP_Query( $args );
$posts = $the_query->posts;
And here is the first part of the output when I do print_r($the_query).
WP_Query Object ( [query] => Array ( [posts_per_page] => 25 [paged] => 1 [post_type] => noo_company [industry] => consulting ) [query_vars] => Array ( [posts_per_page] => -1 [paged] => 1 [post_type] => noo_company [industry] => consulting ...
At first the value for posts_per_page in [query] is ok as I set it, but in the second part [query_vars] it's reset to '-1', and I have no idea why this could be happening.
Thanks in advance for any helpful suggestions.
wp_reset_query();before querying - user2917245