• say i have a category called “design” and i have 15 posts associated with “design”. how do i echo the number of posts with in that category. so in this case i want to echo “15”

    i already have a loop with
    <?php foreach((get_the_category()) as $cat) {?>

    and i can call the ids fine with
    <?php echo $cat->cat_ID ?>

    but i cant retreave the amount of posts.

    i’ve searched and searched :/

    many thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Try print_r($cat) to see what’s there. I’m not sure what version you’re using, but I work on the latest stuff and I know we have $cat->category_count in the 2.1 alpha.

    Thread Starter paulwordpress

    (@paulwordpress)

    yes!
    $cat->category_count works in 2.0.4

    print_r($cat) is also a very handy trick
    thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘the number of posts in a category’ is closed to new replies.