WordPress.org

Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/term description

Description

First available with WordPress Version 2.8, this template tag returns the description of a given term. A term ID and taxonomy are as parameters. If no term ID is passed, the description of current queried term (e.g. post category or tag) will be returned.

Usage

<?php echo term_description$term_id$taxonomy ?>

Parameters

term_id
(integer) (Optional) The ID of the term to return a description.
Default: ID of current query term
taxonomy
(string) (Optional) The slug of the taxonomy the term belongs to. Valid values:
  • 'category'
  • 'post_tag'
  • 'link_category'
  • A custom taxonomy slug
Default: post_tag

Return Values

(string) 
Description of term.

Examples

The default usage returns the description of the current queried term.

<?php $description = term_description(); ?>

Displays a description of the post tag ID 28.

<?php echo 'Term Description: ' . term_description('28','post_tag'); ?>

Displays a description for each item returned by wp_get_nav_menu_items (if they are taxonomy items).

 <?php 
   $myterms = wp_get_nav_menu_items('my-terms');
   foreach ($myterms as $item) {
     // check if it's a taxonomy
     if ($item->type == 'taxonomy') {
       // display the description
       echo term_description($item->object_id, $item->object);
     }
   }
 ?>

Change Log

Notes

  • Output is wrapped in <p> tags.

Source File

term_description() is located in wp-includes/category-template.php.

Related

See also index of Function Reference and index of Template Tags.