the_tags()显示当前文章所属标签的链接

目录

描述

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.

the_tags() 描述

用法

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

the_tags() 用法

参数

$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.

the_tags() 参数

返回值

None.

the_tags() 返回值

示例

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: .

/* ----------------------------------
 * wordpress之魂 © http://wphun.com
 * ---------------------------------- */
<p><?php the_tags(); ?></p>

Separated by Commas

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

/* ----------------------------------
 * wordpress之魂 © http://wphun.com
 * ---------------------------------- */
 <?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:

/* ----------------------------------
 * wordpress之魂 © http://wphun.com
 * ---------------------------------- */
<?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.

/* ----------------------------------
 * wordpress之魂 © http://wphun.com
 * ---------------------------------- */
<?php the_tags( 'Tagged with: ', ' • ', '<br />' ); ?>

A List Example

Displays a list of the tags as an unordered list:

/* ----------------------------------
 * wordpress之魂 © http://wphun.com
 * ---------------------------------- */
<?php the_tags( '<ul><li>', '</li><li>', '</li></ul>' ); ?>

the_tags() 示例

历史

添加于 版本: 2.3.0

the_tags() 历史

相关