term_description() WordPress Function

The term_description() function is used to retrieve the description of a given term. The term can be specified by its ID, slug, or name.

term_description( int $term, null $deprecated = null ) #

Retrieves term description.


Parameters

$term

(int)(Optional) Term ID. Defaults to the current term ID.

$deprecated

(null)(Optional)Deprecated. Not used.

Default value: null


Top ↑

Return

(string) Term description, if available.


Top ↑

More Information

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.

Output is wrapped in <p> tags.


Top ↑

Source

File: wp-includes/category-template.php

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;
}


Top ↑

Changelog

Changelog
VersionDescription
4.9.2The $taxonomy parameter was deprecated.
2.8.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.