WordPress.org

Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/the tags

Description

This template tag displays a link to the tag or tags a post belongs to. If no tags are associated with the current entry, nothing is displayed. This tag should be used within The Loop.

Usage

 <?php the_tags$before$sep$after ); ?> 

Parameters

$before 
(string) Text to display before the actual tags are displayed. Defaults to Tags:
$sep 
(string) Text or character to display between each tag link. The default is a comma (,) between each tag.
$after 
(string) Text to display after the last tag. The default is to display nothing.

Return Values

None.

Examples

Default Usage

The default usage lists tags with each tag (if more than one) separated by a comma (,) and preceded with the default text Tags: .

<p><?php the_tags(); ?></p>

Separated by Commas

Displays a list of the tags with a line break after it.

 <?php the_tags( 'Tags: ', ', ', '<br />' ); ?> 

Separated by Arrow

Displays links to tags with an arrow (>) separating the tags and preceded with the text Social tagging:

<?php the_tags( 'Social tagging: ',' > ' ); ?>

Separated by a Bullet

Displays links to tags with a bullet (•) separating the tags and preceded with the text Tagged with: and followed by a line break.

<?php the_tags( 'Tagged with: ', ' • ', '<br />' ); ?>

A List Example

Displays a list of the tags as an unordered list:

<?php the_tags( '<ul><li>', '</li><li>', '</li></ul>' ); ?>

Source Code

Change Log

Since: 2.3.0

Note About Custom Taxonomies

If you're using your own custom Post Types the_tags() and related functions will not work. You must use the_terms() and its related functions.

Related

Tags: get_tag(), get_tag_link(), get_tags(), get_the_tag_list(), get_the_tags(), is_tag(), the_tags(), single_tag_title(), tag_description(), wp_generate_tag_cloud(), wp_tag_cloud(), the_taxonomies

See also index of Function Reference and index of Template Tags.