I have lots of categories. And each category contains many images in posts.

I want to display '(current number of post)/(total number of posts in selected category)'

for example: 3/9
where 3 = current number of post 9 = total number of posts in selected category

There are so many categories and I do not want to write code for each category. Is there any way to solve it?

  • what is current no of posts ? Aug 30, 2013 at 13:28
  • @wordpresser: There are 9 posts and out of which number 3 post is open.
    – Ninad More
    Aug 30, 2013 at 13:31
  • from your question, what I get is you need not to write code for each category, you can fetch categories as an array and then use foreach loop to calculate the posts for it.
    – Kumar
    Aug 30, 2013 at 13:31
  • I tried $category = get_queried_object(); echo $category->count; but not worked. I dont want to show only total number but also current post number.
    – Ninad More
    Aug 30, 2013 at 13:33
  • An important question - are you trying to display this information on archive or single view?
    – Michal Mau
    Aug 30, 2013 at 15:23

1 Answer 1


WP_Query has the following properties you might find handy:

$wp_query->current_post - Index of the post currently being displayed.

$wp_query->found_posts - The total number of posts found matching the current query parameters


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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