I have a wp_query $wp_query = new WP_Query($args);
but for some reason the $wp_query->post_count
only shows the amount of posts on each page. So if I set 'showposts' => '10'
and 12 results are found, page one will say ’10 results found’ and page 2 shows ‘2 results found’. Why is this? I can’t figure it out.
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array(
'post_type' => 'post',
'showposts' => '10',
'paged' => $paged
);
$wp_query = new WP_Query($args);
echo "Search found ".$wp_query->post_count."results";
if ($wp_query->have_posts()) : while ($wp_query->have_posts()) : $wp_query->the_post();
// the loop
$wp_query->post_count
is supposed to work exactly like that. To get the total number of posts that exist in the database, use$wp_query->found_posts