Last active
August 29, 2015 13:56
-
-
Save pedrorvidal/9188718 to your computer and use it in GitHub Desktop.
Pegar uma custom taxonomy e mostrar ela ordenada com filhos agrupados.
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 | |
$taxonomyName = "slug-da-minha-taxonomia"; | |
$terms = get_terms($taxonomyName,array('parent' => 0)); | |
foreach($terms as $term) : | |
echo '<a href="'.get_term_link($term->slug,$taxonomyName).'">'.$term->name.'</a>'; | |
$term_children = get_term_children($term->term_id,$taxonomyName); | |
echo '<ul>'; | |
foreach($term_children as $term_child_id) : | |
$term_child = get_term_by('id',$term_child_id,$taxonomyName); | |
echo '<li><a href="' . get_term_link( $term_child->name, $taxonomyName ) . '">' . $term_child->name . '</a></li>'; | |
endforeach; | |
echo '</ul>'; | |
endforeach; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment