the_tags

TAG TAGS

What It Does

Displays a link to the tag(s) that the post is associated with. If no tags were used with the post, the category that the post is filed under will be displayed. the_tags must be used within The Loop.

Code

<?php the_tags(‘before’, ‘separator’, ‘after’); ?>

Before

Allows you to specify what text to display before the tags are shown. If no “before” text is specified, “Tags:” will be shown.

Separator

Allows you to specify what to display in between each tag. If no “seperator” is specified, a comma will be used.

After

Allows you to specify what text to display after the tags are shown.

Example

The default usage of the_tags is as follows:

<?php the_tags(); ?>

To manually specify “before”, “separator” and “after” text, you can use something like:

<?php the_tags(‘This Post’s Tags: ‘, ‘ > ‘); ?>

The above example will display something like this:

This Post’s Tags: Finance > Stocks > Wall Street

Notice in the above example, no “after” text was specified.

As another example, you can put the tags in an ordered list:

<?php the_tags(‘This Post’s Tags:<br /><ul><li>’,'</li><li>’,'</li></ul>’); ?>

The above example will display something like this:

This Post’s Tags:

  • Finance
  • Stocks
  • Wall Street