If you want to count the number of posts in any category, there are number of ways to perform this check. Here are some of my ideas that worked.
This one uses PHP count function. You can always set a different condition. Mine is checking if there are more than 10 posts in category with ID 50.
1 2 3 |
if (get_category('50')->count > 10) { //do something } |
Somewhere inside WordPress core (category.php template to be specific), you can also find the category_count function:
1 2 3 |
if (get_category('ID')->category_count > 10) { //do something } |
Which seems to be doing the same.