wp_set_post_tags

函式
wp_set_post_tags ( $post_id = 0, $tags = '', $append = false )
引數
  • (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)
  • (bool) $append Optional. If true, don't delete existing tags, just add on. If false, replace the tags with the new tags. Default false.
    Required:
    Default: false
返回值
  • (array|false|WP_Error) Array of term taxonomy IDs of affected terms. WP_Error or false on failure.
相關
  • wp_set_object_terms()
定義位置
相關方法
wp_get_post_tagswp_set_post_catswp_set_post_termswp_add_post_tagswp_get_post_cats
引入
2.3.0
棄用
-

wp_set_post_tags: 這個函式設定與一個文章相關的標籤。它接受文章的ID和一個標籤名稱或標記的陣列。

設定一個文章的標籤。

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

常見問題

FAQs
檢視更多 >