WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I was able to get all the items of a custom taxonomy for a post, like this:

$args=array('orderby'=>'parent',"fields" => "all");
$term_list = wp_get_post_terms($post->ID, 'tvr_amenity', $args);

My problem is that i would like to show the tree (respecting the parents)

So i would like to get them ordered by name and parent but i cant find anything related on codex..

any idea how?

share|improve this question
up vote 2 down vote accepted

What about:

$taxName = "tvr_amenity";
$terms = get_terms($taxName,array('parent' => 0));
foreach($terms as $term) {
   echo '<a href="'.get_term_link($term->slug,$taxName).'">'.$term->name.'</a>';
   $term_children = get_term_children($term->term_id,$taxName);
   echo '<ul>';
   foreach($term_children as $term_child_id) {
       $term_child = get_term_by('id',$term_child_id,$taxName);
       echo '<li><a href="' . get_term_link( $term_child->name, $taxName ) . '">' . $term_child->name . '</a></li>';
   echo '</ul>';
share|improve this answer
Thats exactly what I was looking for! I love you mate! – Toni Michel Caubet Aug 19 '13 at 18:49

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.