Created
September 5, 2013 19:32
-
-
Save brycejacobson/6454994 to your computer and use it in GitHub Desktop.
WordPress get child terms of current taxonomy page and display them.
This file contains hidden or 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 | |
$taxonomy_name = get_queried_object()->name; // Get the name of the taxonomy | |
$term_id = get_queried_object_id(); // Get the id of the taxonomy | |
$termchildren = get_term_children( $term_id, $taxonomy_name ); // Get the children of said taxonomy | |
// Display the children | |
echo '<tr>'; | |
foreach ( $termchildren as $child ) { | |
$term = get_term_by( 'id', $child, $taxonomy_name ); | |
echo '<td><a href="' . get_term_link( $term->name, $taxonomy_name ) . '">' . $term->name . '</a></td>'; | |
} | |
echo '</tr>'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Generally, this works for me pretty well.
However, if sorting child terms is important to you then you can go through a different route as well.
Hope this was helpful to some. Thanks.