WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
share|improve this question
Have you looked at the variable $wp_query->found_posts as well? – toscho Dec 4 '12 at 13:52
up vote 13 down vote accepted

$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

share|improve this answer
..and as simple as that, it works. Thanks so much guys! – zilj Dec 4 '12 at 14:15

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.