Support » Fixing WordPress » force wp_list_categories NOT to show No catergories

  • I have a custom category list in my side bar
    wp_list_categories(‘child_of=51&hide_empty=1&title_li=&’)

    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

Viewing 3 replies - 1 through 3 (of 3 total)
  • 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.

    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’){
    wp_list_categories(‘child_of=51&hide_empty=1&title_li=&echo=1’)

    }

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

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘force wp_list_categories NOT to show No catergories’ is closed to new replies.