WordPress tag_description() Function

Beginner
4 min read
Updated: Nov 2026
3 examples
Template tag

Definition

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().

Syntax

Call it with no argument on a tag archive, or pass a tag ID.

WordPress
tag_description();
tag_description( 7 );
$text = tag_description();
CallWhat 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.

Full declaration
WordPress
tag_description( int $tag = 0 ): string

Parameters

ParameterDescription
$tagOptional. The tag ID. Default 0, which means the current tag on an archive page.

Return Value

Return ValueDescription
stringThe tag description. It may contain basic HTML such as <p>.
empty stringThe tag has no description, or the ID is not valid.

WordPress Examples

Three short theme examples. Each one has a sample output.

Example 1 — Current tag

Print the description on a tag archive page.

WordPress
<?php
echo tag_description();
?>

How It Works

  1. On a tag archive, WordPress knows the current tag.
  2. tag_description() returns the saved description.
  3. echo prints it on the page.

Example 2 — By tag ID

Show the description of a specific tag.

WordPress
<?php
echo tag_description( 7 );
?>

How It Works

  1. The number 7 is the tag ID.
  2. The function returns the description of that tag.
  3. This works on any page, not only on archives.

Example 3 — Check before printing

Only show the box when the description is not empty.

WordPress
<?php
$text = tag_description();
if ( $text ) {
  echo '<div class="tag-intro">' . $text . '</div>';
}
?>

How It Works

  1. The description is saved in $text.
  2. An empty string is false, so an empty box is never printed.
  3. The wrapper div can be styled in your CSS.

Frequently Asked Questions

It returns the description of a tag as a string. The default is the current tag on a tag archive page.
No. It returns the text. Use echo to print it.
In the WordPress admin, go to Posts > Tags, edit a tag, and fill in the Description field.
tag_description() is a wrapper for tags. term_description() works for any term, such as categories and custom taxonomies.
The text can contain HTML, so esc_html() would show the tags as text. If you want extra safety, use wp_kses_post().

Next: term_description()

Return the description of any term: category, tag, or custom taxonomy.

term_description() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

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