Example 1 — Current tag
Print the description on a tag archive page.
<?php
echo tag_description();
?> How It Works
- On a tag archive, WordPress knows the current tag.
tag_description()returns the saved description.echoprints it on the page.

In WordPress, tag_description() returns the description of a tag. On a tag archive page it reads the current tag. You can also pass a tag ID.
It returns the text as a string. It does not print it, so use echo to show it. It is a small wrapper around term_description().
Call it with no argument on a tag archive, or pass a tag ID.
tag_description();
tag_description( 7 );
$text = tag_description(); | Call | What it does |
|---|---|
tag_description() | Returns the description of the current tag. |
tag_description( 7 ) | Returns the description of the tag with ID 7. |
$text = tag_description() | Saves the description in a variable so you can test it first. |
Add the description in tag.php or archive.php under the archive title.
tag_description( int $tag = 0 ): string | Parameter | Description |
|---|---|
$tag | Optional. The tag ID. Default 0, which means the current tag on an archive page. |
| Return Value | Description |
|---|---|
| string | The tag description. It may contain basic HTML such as <p>. |
| empty string | The tag has no description, or the ID is not valid. |
Three short theme examples. Each one has a sample output.
Print the description on a tag archive page.
<?php
echo tag_description();
?> tag_description() returns the saved description.echo prints it on the page.Show the description of a specific tag.
<?php
echo tag_description( 7 );
?> 7 is the tag ID.Only show the box when the description is not empty.
<?php
$text = tag_description();
if ( $text ) {
echo '<div class="tag-intro">' . $text . '</div>';
}
?> $text.div can be styled in your CSS.Return the description of any term: category, tag, or custom taxonomy.
9 people found this page helpful