I need to get the number of posts from a given category and store it in a variable. I found this in the documentation but I'm not sure to use this to do what I want or if it's even the right direction.
Thanks for your help!
I need to get the number of posts from a given category and store it in a variable. I found this in the documentation but I'm not sure to use this to do what I want or if it's even the right direction.
Thanks for your help!
Not sure if using SELECT is best practice, but this will show the number of cats as $numcats
http://perishablepress.com/press/2006/08/28/display-total-number-of-posts/
Unless I'm missing something that only gives you the total count of all posts where I need the count of posts within specific categories.
Thanks
Maybe combining with this to get the category ID
// get the first category id
function get_first_category_ID() {
$category = get_the_category();
return $category[0]->cat_ID;
}to get the postcount of category 3:
<?php
$categories = get_categories('include=3');
$cat3 =$categories[0]->category_count;
?>This topic has been closed to new replies.