admin管理员组文章数量:1414908
wp_count_terms() counts the number of terms in a taxonomy but not the number of post that have those terms and I've found that wp_count_post() does not accept a taxonomy.
So whats a guy gotta do to count the number of post in a taxonomy term?
Example:
Term: Apples Post: 89 (this is what I want to get, the number of post with the 'Apples' taxonomy)
Thanks!
wp_count_terms() counts the number of terms in a taxonomy but not the number of post that have those terms and I've found that wp_count_post() does not accept a taxonomy.
So whats a guy gotta do to count the number of post in a taxonomy term?
Example:
Term: Apples Post: 89 (this is what I want to get, the number of post with the 'Apples' taxonomy)
Thanks!
Share Improve this question asked Dec 16, 2013 at 20:33 Jon FurryJon Furry 1872 gold badges3 silver badges13 bronze badges1 Answer
Reset to default 9The function you are looking for is get_term() http://codex.wordpress/Function_Reference/get_term
and the code would look something like this:
$term = get_term( 1, 'category' );//for example uncategorized category
echo 'count: '. $term->count;
本文标签: Count number of post in Taxonomy
版权声明:本文标题:Count number of post in Taxonomy? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745167892a2645794.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论