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

    正文概述 知事网   2020-09-13 10:09:19   705

    描述:

    获取文章的标签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信息

    发表评论

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

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