admin管理员组文章数量:1392002
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?)
1 Answer
Reset to default 0The 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' ) );
}
本文标签: wp queryIs there documentation for objects returned by WPQuery
版权声明:本文标题:wp query - Is there documentation for objects returned by WP_Query? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744743151a2622729.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论