I'm wanting to include a taxonomy description in the header on a post template page. I've got the code below working but is it the proper way? Is there a better way to grab and display the description from a custom taxonomy?

    $pubdescs = get_the_terms( $post->ID ,'publication' );

    foreach( $pubdescs  as $pubdesc ) {
        $pub_desc = $pubdesc->description;

    <?php the_category( '<span class="cat-title-pipe" > | </span>' ); ?>
    <span class="alignright">
        <?php echo $pub_desc; unset( $terms ); ?>

The first part of the <h2> header has worked fine for me. It is just getting the current category. I'm now wanting to add the custom taxonomy "publication" description and this does work but is there an easier way?

1 Answer 1


The more proper API way would be using term_description() template tag. It's same in principle as accessing property, but with proper filters and stuff.

Since term lists are usually focused on names, I can't anything that would iterate and list descriptions in one step.

  • Thanks for the response - so you mean trying this: $pubdescs = term_desctiption( $post->ID ,'publication' );
    – Hal Atkins
    Sep 28, 2016 at 17:56
  • No, see linked documentation for how to use it. It accepts term, not post.
    – Rarst
    Sep 28, 2016 at 19:22
  • I'm sorry - I'm lost. If you have time - how would you code that in the post template page?
    – Hal Atkins
    Sep 28, 2016 at 19:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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