WordPress.org

Support

Support » How-To and Troubleshooting » category mesage counts

category mesage counts

  • Just wondering if anybody knows how to get the message count next to the categories on index.php.
    Thanks.

Viewing 9 replies - 1 through 9 (of 9 total)
  • This has been posted often. If you do a search you will find both quick and dirty, as well as lengthy, responses. The quick and dirty is something like, <?php wp_list_cats(0, ‘All’, ‘name’, ‘desc’, ”,1,0,1,1); ?>. The problem for me, however, is it is not working on my installation and I am still scratching my head trying to figure out why.

    Evidentally it is <?php list_cats(0, ‘All’, ‘name’, ‘desc’, ”,1,0,1,1); ?>

    In the new nightlies/CVS, list_cats has been replaced with wp_list_cats, and the ‘old way’ of setting up post/category counts no longer works.

    wp_list_cats() has a different calling convention. It uses named parameters rather than positional parameters. It takes one argument which is a string containing option names and their values. They are separated by ‘&’, just like in a query string. For example, to enable counts do this:
    wp_lists_cats(‘optioncounts=1’);
    To enable counts and dates:
    wp_lists_cats(‘optioncounts=1&optiondates=1’);
    And so on. Add more options as needed, separating each key, value pair with an ampersand. You only need to specify the options you wish to change from the default.

    I just fixed some small bugs with the wp_list_cats() argument processing. Some options, such as optionall, would refuse to be set to 0. Fixed in CVS.

    May I ask, where to put this line:
    <?php list_cats(0, ‘All’, ‘name’, ‘desc’, ”,1,0,1,1); ?>
    to get the category post counts displayed? Thanks!

    Where do you want it? Most put it in sidebar.php but template tags can go in any of the theme’s templates. index.php, home.php, single.php, etc.

    So according to your expanation, this display function only shows on those tamplates that I add this line in their sidebars? I will try it on my current template sidebar now and report back here if I succeed.
    Thank you!!

    Generally speaking, all the templates load the sidebar, if the theme is the basic content/sidebar design. So adding it to sidebar.php, it should show on all the pages that contain the sidebar.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘category mesage counts’ is closed to new replies.