jrodgers
Member
Posted 1 year ago #
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
sophiavancouver
Member
Posted 1 year 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.
jrodgers
Member
Posted 1 year 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'){
wp_list_categories('child_of=51&hide_empty=1&title_li=&echo=1')
}
WPQuestions
Member
Posted 1 year ago #
Good solution jrodgers. In my implementation I had to check if wp_list_categories was equal to "
<li>No Categories</li>
"