Here's my custom function to list child categories by the parent slug.
function ribbon_list_cats($parent_cat_slug)
{
$parent_category = get_category_by_slug($parent_cat_slug);
if ($parent_category->count != 0) {
echo "<ul>";
echo wp_list_categories('title_li=&child_of='.$parent_category->term_id.'&hide_empty=0&show_option_none=&echo=0');
echo "</ul>";
}
}
I'm having trouble getting it to return and output. It doesn't throw an error. I'm using it multiple times so I created this but when I do it like so:
$parent_category = get_category_by_slug('lifestyle');
if ($parent_category->count != 0) {
echo "<ul>";
echo wp_list_categories('title_li=&child_of='.$parent_category->term_id.'&hide_empty=0&show_option_none=&echo=0');
echo "</ul>";
}
right in the template it works fine. But that's a lot of code to repeat over and over again.
Hope that makes sense. Thanks!
ribbon_list_cats('lifestyle') ;
in your template files (which should work)?