Frage

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,

War es hilfreich?

Lösung 2

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

Andere Tipps

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

Ex:

$chlidrenCategories = get_term_children( categoryParentId ,'Category');
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top