Display custom post type in hierarchical order with get_terms
Try something like this: <?php $parent_terms = get_terms( ‘name_of_your_taxonomy’, array( ‘parent’ => 0, ) ); foreach ( $parent_terms as $parent_term ) { $child_terms = get_terms( ‘name_of_your_taxonomy’ array( ‘child_of’ => $parent_term->term_id, ) ); foreach ( $child_terms as $child_term ) { $args = array( ‘post_type’ => ‘product’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘name_of_your_taxonomy’, ‘field’ => ‘slug’, … Read more