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: 該函式返回當前文章或作為引數傳遞給它的文章的標籤物件的陣列。

檢索文章的標籤。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
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 );
}
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 ); }
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
檢視更多 >