Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
List children terms of current taxonomy term
$queried_object = get_queried_object();
$taxonomy = $queried_object->taxonomy;
$term_id = $queried_object->term_id;
$taxonomy_name = 'category';
$term_children = get_term_children($term_id, $taxonomy_name);
echo '<ul class="nav nav-pills">';
foreach ($term_children as $child) {
$term = get_term_by('id', $child, $taxonomy_name);
echo '<li><a class="btn btn-default" href="' . get_term_link($child, $taxonomy_name) . '">' . $term->name . '</a></li>';
echo '</ul>';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment