admin管理员组文章数量:1124388
I am trying to display the post count of some taxonomies. I have a custom template that I am showing some taxonomies on. I am using advanced custom fields to assign each repeater field to a taxonomy. How can I display the amount of post for each one?
I am trying to display the post count of some taxonomies. I have a custom template that I am showing some taxonomies on. I am using advanced custom fields to assign each repeater field to a taxonomy. How can I display the amount of post for each one?
Share Improve this question asked May 2, 2015 at 0:08 JediTricks007JediTricks007 8463 gold badges14 silver badges27 bronze badges1 Answer
Reset to default 0You can use this code for getting number of posts in a taxonomy:
$args = array(
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => -1,
'tax_query' => array(
array(
'taxonomy' => 'your-taxonomy-name',
'field' => 'slug',
'terms' => 'some-slug',
)
)
);
$query = new WP_Query( $args );
echo $query->post_count;
本文标签: How to show amount of post in a taxonomy with advanced custom fields
版权声明:本文标题:How to show amount of post in a taxonomy with advanced custom fields? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736628640a1945729.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论