term_description()WP 2.8.0

Gets the description of the term (taxonomy element: tags, categories, etc.) that is specified on the term creation/editing page.

If the parameter $term_id is not specified, the description of the current term (current category, tag, etc.) will be retrieved.

Filters

To filter the result, use the following filters:

These filters are applied in the function sanitize_term_field(), which is triggered as a result of this function.

No Hooks.

Returns

String. Description of the term or empty - ''.

Usage

term_description( $term, $deprecated );
$term(integer/object)
ID or object of the term (taxonomy element) whose description needs to be retrieved.
If this parameter is not specified, the function will attempt to get the description of the term that is currently in the query. For example, if the "SEO" category page is displayed, the function will get the description of that category.
Default: ID of the current term in the query
$deprecated(string)

Since version 4.9.2 this parameter is deprecated, it is no longer needed (it makes no sense).

Previously, there was a parameter $taxonomy — The name of the taxonomy to which the term belongs, whose description needs to be retrieved. It can be: category, post_tag, link_category or custom taxonomy. If the $term parameter is not specified, this parameter will equal the name of the current term's taxonomy. Default was post_tag.
Default: null

Examples

0

#1 Get a description of the current term (categories, tags, etc.):

$description = term_description();
echo $description;
0

#2 Display the description of the my_tax taxonomy term, which ID is 28:

echo 'Section description: ' . term_description( '28', 'my_tax' );

Changelog

Since 2.8.0 Introduced.
Since 4.9.2 The $taxonomy parameter was deprecated.

term_description() code WP 6.8.3

function term_description( $term = 0, $deprecated = null ) {
	if ( ! $term && ( is_tax() || is_tag() || is_category() ) ) {
		$term = get_queried_object();
		if ( $term ) {
			$term = $term->term_id;
		}
	}

	$description = get_term_field( 'description', $term );

	return is_wp_error( $description ) ? '' : $description;
}