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和一个标签名称或标记的数组。

设置一个文章的标签。

function wp_set_post_tags( $post_id = 0, $tags = '', $append = false ) {
	return wp_set_post_terms( $post_id, $tags, 'post_tag', $append );
}

常见问题

FAQs
查看更多 >