Get term items

<?php $taxonomyName = 'taxonomy_name'; // https://developer.wordpress.org/reference/functions/get_terms/ $parent_terms = get_terms(array( 'taxonomy' => $taxonomyName, 'parent' => 0, 'orderby' => 'name', 'hide_empty' => true, )); foreach ( $parent_terms as $parent_term ) { $terms = get_terms(array( 'taxonomy' => $taxonomyName, 'parent' => $parent_term->term_id, 'hide_empty' => true, 'orderby' => 'name', )); foreach ( $terms as $child_term ) { // Do something } } ?>
Get taxonomy terms and their children

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.