I have successfully listed the terms and sub-terms for my custom taxonomies, but the terms are out of order. With the current code, the list shows up as:
Category1
Category2
SubCat2
SubCategory1
SubSubCat2
SubSubCategory1
What am I missing to get them to show up like this:
Category1
SubCategory1
SubSubCatagory1
Category2
SubCat2
SubSubCat2
My Code:
<?php $args=array('public' => true, '_builtin' => false);
$output = 'names';
$operator = 'and';
$taxonomies=get_taxonomies($args,$output,$operator);
if ($taxonomies) {
foreach ($taxonomies as $taxonomy ) {
$terms = get_terms($taxonomy);
$count = count($terms);
if ( $count > 0 ){
echo '<ul>';
foreach ( $terms as $term ) {
$termlinks= get_term_link($term,$taxonomy);
?> <a href="<?php echo $termlinks; ?>">
<?php echo "<li>" . $term->name . "</li>"; ?></a><?php
}
echo "</ul>";
}
}
}
?>
Hoping someone can help me out! :)