Document directory
- Description
- Usage
- Example
- Default usage
- Separated by arrows
- Separated by dots
- List Example
- Integrate categories and tags
- Parameters
Description
This template tag exists in wordpress2.3 for the first time. It displays a tag for the link or article to the tag. If this article does not have tags, the category of the article will be displayed. This template tag should be used in the loop.
Usage
<?php the_tags('before', 'separator', 'after'); ?>
Example
Display a column of tags separated by commas (,) and wrap them.
<?php the_tags('Tags:', ', ', '<br />'); ?>
Default usage
By default, tags that are separated by commas (, if there are more than two tags) are listed, and the default text tags is added before them:
<p><?php the_tags(); ?></p>
The effect is as follows:
Tags: WordPress, computers, and blogging are separated by arrows
Display the link of tags separated by arrows and add the text social tagging before them:
<?php the_tags('Social tagging: ',' > '); ?>
The effect is as follows:
Social tagging: WordPress> computers> blogging separated by vertices
Display the tag links separated by dots, add the text tagged with before the tag, and add a line break after the tag.
<?php the_tags('Tagged with: ',' • ','<br />'); ?>
The effect is as follows:
Tagged with: WordPress • Computers • blogging List Example
Display labels displayed as a concise (x) HTML list (<ul>/<ol>/<DL>:
The effect is as follows:
- WordPress
- Computers
- Blogging
Integrate categories and tags
If your existing article has a category and you add tags to the article at the same time, you may want to display a combination of categories and tags at the bottom of each article. For example, if a Blog contains a category named "culture" and "Media", you can add a tag named "Arts" and "painting" to an article. For the reader's experience and keeping things clean, you may want to display them as tags:
This code can be implemented only when the classification or tag of this article is not empty:
Tags:
<?php if (the_category(', ')) the_category(); ?>
<?php if (get_the_tags()) the_tags(); ?>
Parameters
Before
(Character) The text displayed before the label. The default value is tags ::
Separator
(Character) the text or character displayed in the middle of each tag link. By default, each tag is separated by a comma (,)..
After
(Character) The text displayed after the last tag. No text is displayed by default.