WordPress custom taxonomy description for each post?

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,

Dave

Leave a Comment