Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I would like to show the number of posts on the category page. How is it possible? I tried to find a solution but no luck..

Thank you!

share|improve this question
add comment

2 Answers

If you are on a category archive you don't need to query all the posts of the category like Christopher Ross suggested and you can't use get_the_category() like Max Yudin suggested unless you are already in the loop.

What you can do is simply get the current category object using get_queried_object() which will hold the post count, ex:

$category = get_queried_object();
echo $category->count;
share|improve this answer
add comment
$category = get_the_category(); 
echo $category[0]->category_count;

See /Function_Reference/get_the_category

Next time when you think about categories just have a close look at category functions in Codex.

share|improve this answer
    
get_the_category() is only available when you are in the loop –  Bainternet Feb 7 '13 at 21:47
add comment

Your Answer

 
discard

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.