返回介绍

the_tags()

发布于 2017-09-11 10:39:57 字数 2976 浏览 840 评论 0 收藏 0

the_tags( string $before = null,  string $sep = ', ',  string $after = '' )

Retrieve the tags for a post.


description


参数

$before

(string) (Optional) Before list.

Default value: null

$sep

(string) (Optional) Separate items using this.

Default value: ', '

$after

(string) (Optional) After list.

Default value: ''


源代码

File: wp-includes/category-template.php

function the_tags( $before = null, $sep = ', ', $after = '' ) {
	if ( null === $before )
		$before = __('Tags: ');

	$the_tags = get_the_tag_list( $before, $sep, $after );

	if ( ! is_wp_error( $the_tags ) ) {
		echo $the_tags;
	}
}

更新日志

Versiondescription
2.3.0Introduced.

相关函数

Uses

  • wp-includes/category-template.php: get_the_tag_list()
  • wp-includes/l10n.php: __()
  • wp-includes/load.php: is_wp_error()

User Contributed Notes

  1. Skip to note content You must log in to vote on the helpfulness of this noteVote results for this note: 1You must log in to vote on the helpfulness of this note Contributed by Codex

    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>' ); ?>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文