catzavencu
Member
Posted 2 years ago #
1. I'm tring to list categories in my header. But i don't want to show child categories and at the same time i want
to show empty categories, since are parents to other categories. If i use "include" or "exclude" parameters it doesn't show empty categories. I tried "hide-empty=0", doesn't work.
2.Suppose I have the categories:
Activities
Summer
Winter
Photo
Black&White
Mountains
Rivers
I have a template for Activities where i want to list child categories links with description. I tried this:
'<?php wp_list_categories('include=5&title_li='); ?>
<?php echo category_description(5); ?>
<?php wp_list_categories('include=6&title_li='); ?>
<?php echo category_description(6); ?>'
where 5 and 6 are the "Summer" & "Winter" category ids. But instead of the category name it only shows flat "No categories"
Any help is very much appreciated, Victor
hide_empty=0 does work, just make sure you spell it correctly. That's an underscore between hide and empty, not a dash/minus character.
catzavencu
Member
Posted 2 years ago #
Thank you Otto.
My second question wasn't very explicit i guess. "Summer" (id 5) and "Winter"(id 6) are child categories of "Activities" and i want to list them on the "Activities" template page, both with description or better, with latest post excerpt in sub-category.
I put this in "Activities" category template
<?php wp_list_categories('include=5&title_li='); ?>
<?php echo category_description(5); ?>
<?php wp_list_categories('include=6&title_li='); ?>
<?php echo category_description(6); ?>
but it shows only the category description. Where the category link should be i only get "No categories".
The "No categories" message means that it didn't find category 5 or 6, or those categories were empty and you did not specify hide_empty=0.
catzavencu
Member
Posted 2 years ago #
I used this
<?php wp_list_categories('include=5&hide_empty=0'); ?>
and i have posts in category 5. Still "no category" comes up.
try this:
<?php wp_list_categories('include=5&hide_empty=0&hierarchical=0'); ?>
catzavencu
Member
Posted 2 years ago #
It's working. Thank you both Otto and Yoshi.