0

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?

6
  • what is current no of posts ? – Prince Singh Aug 30 '13 at 13:28
  • @wordpresser: There are 9 posts and out of which number 3 post is open. – Ninad More Aug 30 '13 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 '13 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 '13 at 13:33
  • An important question - are you trying to display this information on archive or single view? – Michal Mau Aug 30 '13 at 15:23
0

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

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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