最新公告
  • 欢迎您光临知事网,本站秉承服务宗旨 履行“站长”责任,销售只是起点 服务永无止境!立即加入我们
  • WordPress函数wp_get_post_tags()用法 获取文章的标签Tags信息

    描述:

    获取文章的标签Tags信息

    用法:

    <?php wp_get_post_tags( $post_id, $args ) ?>

    参数:

    $post_id
    
    (integer) (可选) The Post ID.
    
    默认值: 0
    
    $args
    
    (array) (可选) Overwrite the defaults. See wp_get_object_terms() for a list of valid options that can be passed.
    
    默认值: array

    示例:

    $t = wp_get_post_tags($post->ID);
    print_r($t);

    返回值:

    Array
    (
    [0] => stdClass Object
    (
    [term_id] => 4
    [name] => tag2
    [slug] => tag2
    [term_group] => 0
    [term_taxonomy_id] => 4
    [taxonomy] => post_tag
    [description] =>
    [parent] => 0
    [count] => 7
    )
    
    [1] => stdClass Object
    (
    [term_id] => 7
    [name] => tag5
    [slug] => tag5
    [term_group] => 0
    [term_taxonomy_id] => 7
    [taxonomy] => post_tag
    [description] =>
    [parent] => 0
    [count] => 6
    )
    
    [2] => stdClass Object
    (
    [term_id] => 16
    [name] => tag6
    [slug] => tag6
    [term_group] => 0
    [term_taxonomy_id] => 16
    [taxonomy] => post_tag
    [description] =>
    [parent] => 0
    [count] => 2
    )
    
    )

    源文件:

    /**
    * Retrieve the tags for a post.
    *
    * There is only one default for this function, called 'fields' and by default
    * is set to 'all'. There are other defaults that can be overridden in
    * {@link wp_get_object_terms()}.
    *
    * @since 2.3.0
    *
    * @param int $post_id Optional. The Post ID. Does not default to the ID of the
    * global $post. Defualt 0.
    * @param array $args Optional. Overwrite the defaults
    * @return array List of post tags.
    */
    function wp_get_post_tags( $post_id = 0, $args = array() ) {
    return wp_get_post_terms( $post_id, 'post_tag', $args);
    }
    找互联网优质资源,上知事网!
    知事网 » WordPress函数wp_get_post_tags()用法 获取文章的标签Tags信息

    常见问题FAQ

    网盘提取密码在哪里?
    在网站右侧有个“文件密码”,点击复制即可!
    网站的积分如何获得?
    注册登录后,每天签到可获得2个积分,每天可签到一次!

    发表评论

    • 1231会员总数(位)
    • 665资源总数(个)
    • 21本周发布(个)
    • 0 今日发布(个)
    • 3457稳定运行(天)

    提供最优质的资源集合

    Mac软件 Dedecms源码
    升级SVIP尊享更多特权立即升级