ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Categories - getting number of posts

August 18, 2008 10:21am

Subscribe [3]
  • #1 / Aug 18, 2008 10:21am

    Doggie52

    113 posts

    I am on the look-out for tags that will help me display the number of posts in each category.
    I already have a list of categories, but I need to display the numbers as well.

    Any ideas? This is what I’ve tried.

    {exp:weblog:categories weblog="{my_weblog}" style="nested" show_empty="no"}
    <a href="http://{path=blog/archive}">{category_name}</a>{exp:weblog:entries weblog="{my_weblog}" category="{category_id}"} ({total_results}) {/exp:weblog:entries}
    {/exp:weblog:categories}

    m

    [Mod edit: moved to How To forum]

  • #2 / Aug 18, 2008 4:42pm

    Ingmar

    29245 posts

    This article might get you started.

  • #3 / Aug 18, 2008 5:54pm

    e-man

    1816 posts

    Combining the query module and a bit of php this seems to do the trick:

    {exp:weblog:categories weblog="{my_weblog}"  style="nested" show_empty="no"}
    <?php $tel=0; ?>
    <a href="http://{path=blog/archive}">{category_name} -- _{exp:query sql="SELECT * FROM exp_category_posts where cat_id='{category_id}' "}_<?php $tel=$tel+1; ?>_{/exp:query}</a> 
    <?php echo $tel;  ?>
    {/exp:weblog:categories}
.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases