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,

有帮助吗?

解决方案 2

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

其他提示

If you have id of category parent ,you can use get_term_children

Ex:

$chlidrenCategories = get_term_children( categoryParentId ,'Category');
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top