返回介绍

get_tag()

发布于 2017-09-11 00:16:09 字数 2056 浏览 1079 评论 0 收藏 0

get_tag( int|WP_Term|object $tag,  string $output = OBJECT,  string $filter = 'raw' )

Retrieve post tag by tag ID or tag object.


description

If you pass the $tag parameter an object, which is assumed to be the tag row object retrieved the database. It will cache the tag data.

If you pass $tag an integer of the tag ID, then that tag will be retrieved from the database, if it isn’t already cached, and pass it back.

If you look at get_term(), then both types will be passed through several filters and finally sanitized based on the $filter parameter value.


参数

$tag

(int|WP_Term|object) (Required) A tag ID or object.

$output

(string) (Optional) The required return type. One of OBJECT, ARRAY_A, or ARRAY_N, which correspond to a WP_Term object, an associative array, or a numeric array, respectively.

Default value: OBJECT

$filter

(string) (Optional) Default is raw or no WordPress defined filter will applied.

Default value: 'raw'


返回值

(WP_Term|array|WP_Error|null) Tag data in type defined by $output parameter. WP_Error if $tag is empty, null if it does not exist.


源代码

File: wp-includes/category.php

function get_tag( $tag, $output = OBJECT, $filter = 'raw' ) {
	return get_term( $tag, 'post_tag', $output, $filter );
}

更新日志

Versiondescription
2.3.0Introduced.

相关函数

Uses

  • wp-includes/taxonomy.php: get_term()

User Contributed Notes

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

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

发布评论

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