wp_add_post_tags

函式
wp_add_post_tags ( $post_id = 0, $tags = '' )
引數
  • (int) $post_id Optional. The Post ID. Does not default to the ID of the global $post.
    Required:
  • (string|array) $tags Optional. An array of tags to set for the post, or a string of tags separated by commas. Default empty.
    Required:
    Default: (empty)
返回值
  • (array|false|WP_Error) Array of affected term IDs. WP_Error or false on failure.
相關
  • wp_set_post_tags()
定義位置
相關方法
wp_set_post_tagswp_get_post_tagsadd_post_metaadd_posts_pagewp_set_post_cats
引入
2.3.0
棄用
-

wp_add_post_tags: 這個函式用來給一個文章或多個文章新增標籤: 該函式需要兩個引數:$post_id和$tags。$post_id是要新增標籤的文章的ID,而$tags是要新增到文章中的標籤名稱的陣列。

新增標籤到一個文章。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function wp_add_post_tags( $post_id = 0, $tags = '' ) {
return wp_set_post_tags( $post_id, $tags, true );
}
function wp_add_post_tags( $post_id = 0, $tags = '' ) { return wp_set_post_tags( $post_id, $tags, true ); }
function wp_add_post_tags( $post_id = 0, $tags = '' ) {
	return wp_set_post_tags( $post_id, $tags, true );
}

常見問題

FAQs
檢視更多 >