In a Wordpress blog, I'd like to put the term description of a specific custom taxonomy in the footer of each article.

Is this possible? I've tried

<?php term_description( $term_id, $taxonomy ) ?>

but no luck. Unless I'm using it incorrectly? When used, nothing shows up.

  • OK, and what's in your $term_id, $taxonomy?
    – Olexandr Skrypnyk
    Oct 10 '11 at 16:06
  • Well, $term_id is different from post to post. The $taxonomy would be consistent, in this case it's projects.
    – Scott Chandler
    Oct 10 '11 at 16:11

sounds like a silly question but are you echo'ing it out?

<?php echo term_description($term_id, $taxonomy); ?>

otherwise you'll need to get the current post's terms (where my_term is your custom taxonomy):

$terms = wp_get_post_terms( $post->ID, 'my_term' ) 

then get the description for the first term in ther array:

echo term_description($terms[0]->term_id, 'my_term');

I've not tested this but it should put you in the right direction.

So here's the full code below (should go in the single.php or loop.php or wherever your single post is created)...paste it inside the loop:

    <?php $my_taxonomy = 'projects'; // set this to whatever your custom taxonomy is called

$terms = wp_get_post_terms( $post->ID, $my_taxonomy ); // this gets all the terms attached to the post for your custom taxonomy

echo term_description($terms[0]->term_id, $my_taxonomy); // this displays the description for the first term in the $terms array ?>

Hope it helps,


  • Hmm, okay. Thank you. But how exactly do I put this all together? I'm still pretty new to PHP.
    – Scott Chandler
    Oct 10 '11 at 20:12
  • 1
    ok well assuming you are familiar with the WordPress loop all you need to do is place the above code wherever you want inside the loop (ive updated the answer) Oct 10 '11 at 21:35
  • 1
    also edited as I posted the wrong function, and I've also added 'projects' as the taxonomy :-) Oct 10 '11 at 21:50
  • Thanks, but it's still not working for me. Here's what I have in the single.php file: <?php get_header(); ?> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <?php $my_taxonomy = 'projects'; $terms = wp_get_post_terms( $post->ID, $my_taxonomy ) ?> <article <?php post_class() ?> id="post-<?php the_ID(); ?>"> <h1><a href="<?php the_permalink() ?>"> <?php the_title(); ?></a></h1> <div class="entry"> <?php the_content(); ?> </div> <?php echo term_description($terms[0]->term_id, $my_taxonomy); ?> </article><?php endwhile; ?> <?php get_footer(); ?>
    – Scott Chandler
    Oct 10 '11 at 22:32
  • 1
    Hi Scott, no worries. I've tried the above code and its works spot on for me? Could you show me how you're creating the custom taxonomy? Think that might be the issue. You also need an endif; just before you call get_footer. I missed a ; out the code above so ive updated it again. Oct 11 '11 at 7:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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