Search code examples
phpwordpresswp-list-categories

Remove parent item in a sub category list (wp_list_categories)


UPDATE: Nevermind, stupid error: it wasn't actually showing the parent title, it was a sub category with the same name.

I have the following list to display the child categories of the current category and I'd like to remove or hide the parent item, showing only the children. Is it possible without writing a function in functions.php?

HTML:

<div class="tabs">  
    <ul>
        <?php $this_cat = (get_query_var('cat')) ? get_query_var('cat') : 1; ?>
        <?php $this_category = get_category($this_cat);
        if ( $this_category->parent ) { $this_cat = $this_category->parent; } ?>
        <?php wp_list_categories('child_of=' . $this_cat . '&title_li='); ?>
    </ul>
</div>

RESULT:

"issue of the year" is the parent which I want to remove

enter image description here

Thanks,


Solution

  • Nevermind, stupid error: it wasn't actually showing the parent title, it was a sub category with the same name.