函数原型
get_the_tags( int|WP_Post $post ): WP_Term[]|false|WP_Error
函数描述
Retrieves the tags for a post.
是否弃用
未弃用
函数参数
-
$post
int|WP_Post
Required - Post ID or object.
函数返回值
WP_Term[]|false|WP_Error Array of WP_Term objects on success, false if there are no terms or the post does not exist, WP_Error on failure.
函数位置
File: wp-includes/category-template.php.
函数源码
<?php
$posttags = get_the_tags();
if ($posttags) {
foreach($posttags as $tag) {
echo $tag->name . ' ';
}
}
?>源码链接
变更日志
| Version | Description |
|---|---|
| 2.3.0 | Introduced. |

