I have made a product page. Wich lists all products site.com/products. At the product page there is a navigation wich lists all the terms in the taxonomy 'kategori'. The taxonomy is set to hierarchical, so i can make parent terms. I list all the terms with:
<div class="produkt_nav"><h3><a href="/produkter/">Produkter</a></h3>
<?php $cam_brands = get_terms('kategori', 'hide_empty=1'); ?>
<ul>
<?php foreach( $cam_brands as $brand ) : ?>
<li>
<a href="<?php echo get_term_link( $brand->slug, 'kategori' ); ?>">
<?php echo $brand->name; ?>
</a>
<?php endforeach ?>
</ul>
</div>
It gives me:
- Main category
- Main 2 category
- Parent to main 3
- Main 3 category
- Main 4 category
I need to change the code so i get it to show:
- Main category
- Main 2 category
- Main 3 category
X Parent to main 3
- Main 4 category
How can put a different class to parent terms and list the terms as a tree?
$brand->parent_ID
, if set apply new class. Other than that, I'd suggest you use a custom Walker codex.wordpress.org/Function_Reference/Walker_Class instead of a loop.wp_list_categories