I have this in my category.php
to show sub-subcategories:
<?php if (is_category()) {
$this_category = get_category($cat);
if (get_category_children($this_category->cat_ID) != "") {
echo "<ul>";
wp_list_categories('orderby=id&show_count=0&title_li=
&use_desc_for_title=1&child_of='.$this_category->cat_ID);
echo "</ul>";
}
}?>
<ul>
<li class="cat-item cat-item-5">
<a>subcategory</a>
<ul class="children">
<li class="cat-item cat-item-6"><a>sub-subcategory1</a></li>
<li class="cat-item cat-item-7"><a>sub-subcategory2</a></li>
</ul>
</li>
</ul>
Is it possible to add a class with the sub-subcategory name?
<li class="cat-item cat-item-6 sub-subcategory1"><a>sub-subcategory1</a></li>
Yes, it is possible.
wp_list_categories
accepts a (custom) walker that may handle this.Put the following in your
functions.php
file:Then, change your code in
category.php
like so:I know that this question is old, but I found another solution that seems to be simpler than a custom walker, and wanted to post it for anyone else looking for a solution. You can use the
category_css_class
filter.