Domanda

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,

È stato utile?

Soluzione 2

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

Altri suggerimenti

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

Ex:

$chlidrenCategories = get_term_children( categoryParentId ,'Category');
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top