문제

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