term_description()
Retrieve term description.
Uses: get_term_field()
No Hooks.
Return
String
. Term description, if available.
Usage
term_description( $term, $deprecated );
- $term(int)
- Term ID.
Default: current term ID - $deprecated(null)
- Deprecated. Not used.
Default: null
Examples
#1 Get a description of the current term (categories, tags, etc.):
$description = term_description(); echo $description;
#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() term description code WP 6.7.1
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; }