How can I display a term's name & description for a custom taxonomy within The Loop (single post page template)?

Currently I can show its name like this:

the_terms( $post->ID , 'director', 'director: ');

but can't get the description

I dont want to use extra php coding like:

$directors = get_the_terms($post->ID ,'director');
foreach($directors as $director){
    $director_name = $director->name;
    $director_desc = $director->description;
  • Maybe this will help you: get_the_terms() – Sven May 30 '14 at 9:35
  • I should do some itteration uppon using get_the_term. I will add edit to clear out my question more. thanks though – biji buji May 30 '14 at 10:00
  • You could put a custom function in your functions.php and call it from your template files... – Sven May 30 '14 at 13:38

Have a look at get term(). This return the name and description for a term.

Here is the axamples given in the codex

Gives you term name: e.g. Term Name Example

$name = $term->name;

Gives you term description: e.g. This is my new cool custom term.

$desc = $term->description;

  • 1
    documentation: Get all Term data from database by Term ID. I dont want to contact DB again! – biji buji May 30 '14 at 9:47

Get the term first

$current_term = get_term_by( 'slug', 'category-slug', 'taxonomy' );

Display the description

echo $current_term->description;

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.