wp query - WP_Query to display number of custom post type filtered (order by) taxonomy

I am trying to display the number of posts made in custom post type "incidents" by the custom taxonomy "s

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 badge
Add a comment  | 

1 Answer 1

Reset to default 0

You 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';

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745187942a4615726.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信