Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jesders/54cc7e828973f6db83d233806ecf96ef to your computer and use it in GitHub Desktop.
Save jesders/54cc7e828973f6db83d233806ecf96ef to your computer and use it in GitHub Desktop.
Get Parent -> Child Terms (With or Without Custom Taxonomy)
<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