admin管理员组文章数量:1415460
I am trying to display the number of posts made in custom post type "incidents" by the custom taxonomy "store".
eg.
Store 1: 8 posts
Store 2: 6 posts
etc.
I have been looking through here and only been able to find how to display the actual posts, which I do not need. Thanks for any help!
I am trying to display the number of posts made in custom post type "incidents" by the custom taxonomy "store".
eg.
Store 1: 8 posts
Store 2: 6 posts
etc.
I have been looking through here and only been able to find how to display the actual posts, which I do not need. Thanks for any help!
Share Improve this question asked Sep 3, 2019 at 17:57 AquitelloAquitello 11 bronze badge1 Answer
Reset to default 0You could try running a custom query for each:
$args_1 = array(
'post_type' => 'incidents',
'post_status' => 'published',
'posts_per_page' => -1,
'tax_query' => array(
array(
'taxonomy' => 'store',
'field' => 'name',
'terms' => 'store_1',
),
),
);
$count_1 = count( get_posts( $args_1 ) );
echo 'Store 1: ' . $count_1 . ' posts';
本文标签: wp queryWPQuery to display number of custom post type filtered (order by) taxonomy
版权声明:本文标题:wp query - WP_Query to display number of custom post type filtered (order by) taxonomy 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745187942a2646773.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论