I've managed to do this from a single.php
file, inside the loop, but now I need to do it from another page.
I need to find out how many live posts are in category named every story
(slug is everystory
). I am not inside the loop.
I just need the number, I don't need to output anything except the number. E.g 8
I have tried searching for a way to gather category data just via the category_name
(could be name, or could be slug, could even be by category ID
) but everything I've found so far refers to using a specific $post
var and finding it's category which isn't what I want to do.
Here is the example of what I used on the single
post page:
$category = get_the_category();
$counter = $category[0]->category_count;