Getting JUST the top-level category names (parent)
-
wp: latest
theme: notoriousIn the backend, I have a section called portofolio, with few categories as follows: drinks, food, whatever.
In each one of these I’ve got two or three more subcategories and the subcategories all have few posts.
Ex:
drinks
-juices
-etc
-bla bla
food
-fish
-meat
-veggieNow, on the portfolio page I have this foreach to get the top level category names out but my function:
$terms = get_terms('portfoliocategory', 'hide_empty=1&pad_counts=1&child_of=0'); $count = count($terms);
..gets out the names of each category and sub-category. I only need the top-level ones (without alterating the structure tree of these categories).
What function should I use, what arguments, any examples/hints please? I think I have tried everything.
Thank you.
and part of my foreach:
foreach ( $terms as $term ) { echo '<li class="'.$term->name.'"> <a class="portfoliobutton_noselect" href="#">'.$term->name.'</a></li>';} ETC, ETC
- The topic ‘Getting JUST the top-level category names (parent)’ is closed to new replies.