最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

wp query - Is there documentation for objects returned by WP_Query?

programmeradmin1浏览0评论

I'm running a cusotm WP_Query to get a handful of posts based on some parameters. Once I have the posts and I'm looping over them, I need to extract certain metadata elements, such as a list of tags for the post.

I see there's a function get_the_tags for fetching an array of "tag objects", but I'm not seeing any references to where those are documented (i.e. what properties/methods do the tag objects have?)

I'm running a cusotm WP_Query to get a handful of posts based on some parameters. Once I have the posts and I'm looping over them, I need to extract certain metadata elements, such as a list of tags for the post.

I see there's a function get_the_tags for fetching an array of "tag objects", but I'm not seeing any references to where those are documented (i.e. what properties/methods do the tag objects have?)

Share Improve this question asked Feb 17, 2020 at 6:20 bertdaybertday 1196 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

The tag objects returned by get_the_tags() use WP_term class. You can see this by inspecting the function's source. The class is mentioned on the last line of the comment.

function get_the_tags( $id = 0 ) {

    /**
     * Filters the array of tags for the given post.
     *
     * @since 2.3.0
     *
     * @see get_the_terms()
     *
     * @param WP_Term[] $terms An array of tags for the given post.
     */
    return apply_filters( 'get_the_tags', get_the_terms( $id, 'post_tag' ) );
}
发布评论

评论列表(0)

  1. 暂无评论