WordPress tutorials: Number of posts in a category

Wpsnipp – WordPress allows you to vary how many blog posts you show on your blog, but it’s a single setting, and affects how many blog posts show over the whole website. This tip allows you to have a different number of posts for a particular category.

Adding this PHP code to your wordpress theme will display the total number of posts within the specified category.



$chosen_id = 5; // category number
$thisCat = get_category($chosen_id);
echo $thisCat->count;

Leave a comment