I have a taxonomy called region with a hierarchical structure;
• Southern Africa
• Botswana
• South Africa
• Zambia
• Zimbabwe
In my taxonomy-region.php template file I would like to list the child terms when on Southern Africa (parent) and show nothing when on Botswana (child).
I have the following code where I'd like it to display:
<?php
$current_term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' )); ?>
<h5>Countries</h5>
<?php $cats = wp_list_categories( array(
'parent' => $current_term->term_id,
'taxonomy' => $current_term->taxonomy,
'hide_empty' => 0,
'hierarchical' => true,
'depth' => 2,
'title_li' => ''
));
?>
<ul>
<?php foreach ((array)$cats as $cat) {
echo '<li><a href="'. get_category_link($cat).'" title="'. $cat->$cat_name .'">' . $cat->cat_name . '</a></li>'; }
?>
</ul>
Any help would be appreciated.