Created
April 29, 2020 10:58
-
-
Save delvinkrasniqi/629c805a16e3d4f950299c5c88f94395 to your computer and use it in GitHub Desktop.
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
<?php | |
$taxonomy = 'product_categories'; | |
$args = array( | |
'parent' => 0 // to get only parent terms | |
); | |
$terms = get_terms( $taxonomy, $args ); | |
foreach( $terms as $term ) { | |
$children = get_terms( $taxonomy, array( | |
'parent' => $term->term_id, | |
) ); | |
echo $term->slug .'<br>'; | |
foreach ($children as $child){ | |
$kid= $child->slug .'<br>'; | |
echo $kid; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment