The_tags function of WordPress

Source: Internet
Author: User
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: ',' &bull; ','<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>:

  • Codex
  • Tag
  • Theme

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.