force wp_list_categories NOT to show No catergories (4 posts)

  1. jrodgers
    Posted 8 years ago #

    I have a custom category list in my side bar

    as there are no sub categories to category 51 it return 'No categories', what i want is for it to show nothing if there are no active child categories, and i would rather not alter the actual function

  2. sophiavancouver
    Posted 8 years ago #

    Yes, I'm looking for the same thing too. I'm sure there must be a file somewhere that contains the 'no categories' text that is called when no categories show up, and I've been looking for it to delete that comment. Any pointers from anyone on where that is located? There doesn't seem to be anything in the usage for wp_list_categories that allows me to turn the error message 'no categories' off.

  3. jrodgers
    Posted 8 years ago #

    what i ended up doing was running the category call with no echo, checking if the return was No Categories and outputting based on that...

    if(wp_list_categories('child_of=51&hide_empty=1&title_li=&echo=0') != 'No Categories'){


  4. WPQuestions
    Posted 7 years ago #

    Good solution jrodgers. In my implementation I had to check if wp_list_categories was equal to "
    <li>No Categories</li>

Topic Closed

This topic has been closed to new replies.

About this Topic