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 am using this code to display description of a taxonomy.

<?php $my_taxonomy = 'institute'; $terms = wp_get_post_terms( $post->ID, $my_taxonomy ); echo term_description($terms[0]->term_id, $my_taxonomy); ?>

What to do if I want to show description of sub or even sub-taxonomy?

share|improve this question
Btw, does term_description work with custom taxonomies? The codex doesn't say so and I haven't tried it yet. – Rutwick Gangurde Dec 21 '11 at 6:56
up vote 0 down vote accepted

Term description works only with term id and the taxonomy name, so if you want to get the sub term's description, you should first get all the children of a term(and their children, if its another level deep) and loop over their ids with a single term_description call per id.

    $my_taxonomy = 'institute';
    $terms = wp_get_post_terms( $post->ID, $my_taxonomy );
    echo term_description($terms[0]->term_id, $my_taxonomy);

    //Assuming you have only 1 parent term, if multiple then loop over the $terms array
    $term_children = get_term_children( $terms[0]->term_id, $my_taxonomy );

    foreach($term_children as $term_child)
        echo term_description($term_child->term_id, $my_taxonomy).'<br />';

This should give you an idea.

share|improve this answer

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.