get_the_tags

函数
get_the_tags ( $post = 0 )
参数
  • (int|WP_Post) $post Post ID or object.
    Required:
返回值
  • (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.
定义位置
相关方法
get_the_tag_listget_the_termsthe_tagsget_tagsget_theme_data
引入
2.3.0
弃用
-

get_the_tags: 该函数返回当前文章或作为参数传递给它的文章的标签对象的数组。

检索文章的标签。

function get_the_tags( $post = 0 ) {
	$terms = get_the_terms( $post, 'post_tag' );

	/**
	 * Filters the array of tags for the given post.
	 *
	 * @since 2.3.0
	 *
	 * @see get_the_terms()
	 *
	 * @param WP_Term[]|false|WP_Error $terms Array of WP_Term objects on success, false if there are no terms
	 *                                        or the post does not exist, WP_Error on failure.
	 */
	return apply_filters( 'get_the_tags', $terms );
}

常见问题

FAQs
查看更多 >