Why this counting posts system doesn't work ? (2 posts)

  1. Dunkkan
    Posted 7 years ago #

    Hi guys,

    I'd like to list, in a fancy way and outside the loop, some categories and how many posts they include.

    For instance, I've found this useful info.

    But, why this other code isn't working for me ?

    	$cat_posts = get_posts('category_name=BLAH');
    		'<h5 class="italic">There are '
    		. count($cat_posts) .
    		' Posts in <a href="http://url.com/blog/category/blah/">BLAH CATEGORY</a></h5>';

    For some cats is working, for other it shows me less than there are.

  2. Dunkkan
    Posted 7 years ago #

    Here I found and easy, clean way too

    $mycats=get_categories ('include=14');
    echo 'my cat count is '. $mycats[0]->category_count;

    That's working perfectly.

Topic Closed

This topic has been closed to new replies.

About this Topic