Example 1 — Default tag list
Print the tags with the default settings.
<?php the_tags(); ?> How It Works
- The default label is
Tags:. - Each tag is a link to its tag archive.
- A comma and a space go between the tags.

In WordPress, the_tags() prints the tags of the current post as links. Each link goes to the page that lists all posts with that tag.
If the post has no tags, nothing is printed.
A few ways to call the_tags().
<?php
the_tags( 'Tags: ', ', ', '' ); | Call | What it does |
|---|---|
the_tags() | Print Tags: followed by the tag links, separated by commas. |
the_tags( 'Topics: ', ' | ' ) | Use your own label and separator. |
the_tags( '<p>Tags: ', ', ', '</p>' ) | Wrap the tags in a paragraph. |
get_the_tag_list() | Return the same HTML as a string. |
It prints the tag list. The arguments are before, separator, after.
the_tags( string $before = null, string $sep = ', ', string $after = '' ): void | Parameter | Description |
|---|---|
$before | string. Text before the tags. Default is Tags:. |
$sep | string. Text between tags. Default is ,. |
$after | string. Text after the tags. Default is empty. |
| Return Value | Description |
|---|---|
| void | Nothing is returned. The links are printed, or nothing if the post has no tags. |
Three short examples. Each one shows the code and what it prints.
Print the tags with the default settings.
<?php the_tags(); ?> Tags:.Change the text around the tags.
<?php the_tags( 'Topics: ', ' | ', '' ); ?> Use before and after to add HTML, only when tags exist.
<?php the_tags( '<p class="tags">Tags: ', ', ', '</p>' ); ?> Open the functions index for simple guides with examples and FAQs.
11 people found this page helpful