Created
August 19, 2018 12:45
-
-
Save wpchannel/b9ffce61137a113ba31d90385d623068 to your computer and use it in GitHub Desktop.
List children terms of current taxonomy term
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$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