[resolved] How to Show Empty Categories !!? (6 posts)

  1. senaia
    Posted 9 years ago #


    I have searched for this but no luck. Im new here and this is my first serios blog so I need to get everything right before launching it.

    Empty Categories don't show up in the sidebar, how to change this ?

    What file do I need to modify and with what code ?

    Edit: Also, how to show categories according to ID's and not titles :)

    Thank You.

  2. MichaelH
    Posted 9 years ago #

    You'll need the hide_empty parameter for the template tag, wp_list_categories.

    An example of this is the WordPress Default 1.6 Theme where wp-content/themes/default/sidebar has this code

    <?php wp_list_categories('show_count=1&title_li=<h2>Categories</h2>'); ?>

    you would change to this code:

    <?php wp_list_categories('hide_empty=0&show_count=1&title_li=<h2>Categories</h2>'); ?>

    Also see:
    Stepping into Templates
    Stepping into Template Tags
    Template Hierarchy

  3. senaia
    Posted 9 years ago #

    Thanks a million. Its working.

    Do you happen to know how to have categories listed in the sidebar according to ID's :)

    Thank You.

  4. Doodlebee
    Posted 9 years ago #

    it does that by default.

    He provided several links that explain all of that for you.

  5. senaia
    Posted 9 years ago #

    I did not notice the links he provided, just grapped the code and ran to try it :)

    To sort categories by id and show empty one's at the same time:

    <?php wp_list_categories('orderby=id&hide_empty=0&show_count=1&title_li=<h2>Categories</h2>'); ?>

    Thank You :)

  6. amitpatel3001
    Posted 8 years ago #

    Excellent thread, helped me out while i was searching for the same on other blogs.

Topic Closed

This topic has been closed to new replies.

About this Topic