Skip to content

Instantly share code, notes, and snippets.

@delvinkrasniqi
Created April 29, 2020 10:58
Show Gist options
  • Save delvinkrasniqi/629c805a16e3d4f950299c5c88f94395 to your computer and use it in GitHub Desktop.
Save delvinkrasniqi/629c805a16e3d4f950299c5c88f94395 to your computer and use it in GitHub Desktop.
<?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