WordPress term_description() Function

Definition
In WordPress, term_description() returns the description of a term. A term can be a category, a tag, or a term from a custom taxonomy.
It returns the text as a string. It does not print it, so use echo to show it. On a term archive it reads the current term when you pass no ID.
Syntax
Call it with no argument on a term archive, or pass a term ID.
term_description();
term_description( 12 );
$text = term_description();
| Call | What it does |
|---|
term_description() | Returns the description of the current term on an archive page. |
term_description( 12 ) | Returns the description of the term with ID 12. |
$text = term_description() | Saves the description in a variable so you can test it first. |
A term ID is unique, so you do not need to give the taxonomy name.
Full declaration
term_description( int $term = 0, string $deprecated = null ): string
Parameters
| Parameter | Description |
|---|
$term | Optional. The term ID. Default 0, which means the current term on an archive page. |
$deprecated | Optional. The old taxonomy argument. WordPress no longer uses it. Leave it out. |
Return Value
| Return Value | Description |
|---|
| string | The term description. It may contain basic HTML such as <p>. |
| empty string | The term has no description, or the ID is not valid. |
WordPress Examples
Three short theme examples. Each one has a sample output.
Example 1 — Current term
Print the description on any category, tag, or taxonomy archive.
<?php
echo term_description();
?>
<p>Movies that make you laugh.</p>
How It Works
- On an archive page, WordPress knows the current term.
term_description() returns the saved description.- The same code works for categories, tags, and custom taxonomies.
Example 2 — By term ID
Show the description of a specific term.
<?php
echo term_description( 12 );
?>
<p>Short guides for people who are new to WordPress.</p>
How It Works
- The number
12 is the term ID. - The function returns the description of that term.
- This works on any page, not only on archives.
Example 3 — Title and description together
Build a simple archive header.
<?php
$text = term_description();
?>
<header class="archive-header">
<h1><?php single_term_title(); ?></h1>
<?php if ( $text ) : ?>
<div class="archive-description"><?php echo $text; ?></div>
<?php endif; ?>
</header>
<header class="archive-header">
<h1>Comedy</h1>
<div class="archive-description"><p>Movies that make you laugh.</p>
</div>
</header>
How It Works
single_term_title() prints the term name.term_description() returns the description text.- The
if hides the box when there is no description.
Frequently Asked Questions
It returns the description of a term as a string. The default is the current term on an archive page.
Yes. It works for any taxonomy, including categories, tags, and custom taxonomies.
No. The second argument is deprecated and WordPress ignores it. Leave it out.
No. It returns the text. Use echo to print it.
category_description() and tag_description() are small wrappers. term_description() is the general function behind them.
About the author
Developer, cloud engineer, and technical writer
I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.
9 people found this page helpful