Created
May 8, 2020 18:02
-
-
Save jesders/54cc7e828973f6db83d233806ecf96ef to your computer and use it in GitHub Desktop.
Get Parent -> Child Terms (With or Without Custom Taxonomy)
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
<nav> | |
<?php | |
foreach( get_terms( 'tax_pipeline', array( 'hide_empty' => true, 'parent' => 0 ) ) as $parent_term ) { | |
// display top level term name | |
echo $parent_term->name . '<br>'; | |
foreach( get_terms( 'tax_pipeline', array( 'hide_empty' => true, 'parent' => $parent_term->term_id ) ) as $child_term ) { | |
// display name of all childs of the parent term | |
echo '>>>>>' . $child_term->name . '<br>'; | |
} | |
} | |
?> | |
</nav> | |
CAN BE SIMPLIFIED TO | |
<?php wp_list_categories( 'taxonomy=tax_pipeline' ); ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment