Created
December 9, 2015 13:18
-
-
Save croosen/19b427ed97f6b564ccaa to your computer and use it in GitHub Desktop.
Groups WP taxonomies by parent
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
foreach( get_terms( 'product-categories', array( 'hide_empty' => false, 'parent' => 0 ) ) as $parent_term ) { | |
// display top level term name | |
echo $parent_term->name; | |
foreach( get_terms( 'product-categories', array( 'hide_empty' => false, 'parent' => $parent_term->term_id ) ) as $child_term ) { | |
// display name of all childs of the parent term | |
echo $child_term->name; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment