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

When you go to something like: site.com/?cat=2&page=2

you might see 3 posts, the page before might have 5 posts. I am looking for a way to count the posts on a given page. so if I am on page 2, with three posts, said function should return 3.

any idea?

share|improve this question
up vote 3 down vote accepted

The query object contains the member var post_count which will give you the number of posts on the current page:


Also, for the total number of posts for the query (across all pages):


and the number of pages in the query:

share|improve this answer
Post count gives me 26 back when I only have 13 posts in total and 10 on a given page...... This is for a category. there is a maximum of 2 pages. It returns 7 pages for max_num_posts. There are 13 posts for this category....wheres 26 coming from? and the 7? – TheWebs Jul 25 '13 at 15:35

why not do a count?

 <?php count( $wp_query->posts ); ?>
share|improve this answer
"This answer was automatically flagged as low-quality because of its length and content", which I am sure you don't want. Please explain why this could solve the problem. – s_ha_dum Jul 24 '13 at 22:26

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.