最新公告
  • 欢迎您光临知事网软件APP资源下载站,一个优质的手机App应用商店和网站源码基地。欢迎加入永久SVIP
  • WordPress函数wp_set_post_tags()用法 设置文章的标签Tags信息

    正文概述 知事网   2020-09-13 11:09:41   630

    描述:

    使用代码设置一篇文章的标签Tags信息

    用法:

    <?php wp_set_post_tags( $post_ID, $tags, $append ) ?>

    参数:

    $post_ID
    
    (integer) (必填) 文章ID
    
    默认值: 0
    
    $tags
    
    (string,array) (可选) 标签
    
    默认值: array
    
    $append
    
    (boolean) (可选) 如果为true,则标记将附加到帖子中。如果为false,标签将替换现有的标签。
    
    默认值: false

    示例:

    wp_set_post_tags( 42, 'meaning,life', true );

    源文件:

    /**
    * Set the tags for a post.
    *
    * @since 2.3.0
    *
    * @see wp_set_object_terms()
    *
    * @param int $post_id Optional. The Post ID. Does not default to the ID of the global $post.
    * @param string $tags Optional. The tags to set for the post, separated by commas.
    * Default empty.
    * @param bool $append Optional. If true, don't delete existing tags, just add on. If false,
    * replace the tags with the new tags. Default false.
    * @return array|false|WP_Error Array of affected term IDs. WP_Error or false on failure.
    */
    function wp_set_post_tags( $post_id = 0, $tags = '', $append = false ) {
    return wp_set_post_terms( $post_id, $tags, 'post_tag', $append);
    }

    知事网 » WordPress函数wp_set_post_tags()用法 设置文章的标签Tags信息

    发表评论

    还没有评论,快来抢沙发吧!

    [!--temp.right--]
    请选择支付方式
    ×
    余额支付
    ×
    微信扫码支付 0 元