WordPress – Get Post Count In Custom Taxonomy
To get total custom post count of a custom taxonomy use the follow code
$args = array(
'post_type' => 'post type name here',
'post_status' => 'published',
'taxonomy name here' => 'slug of the category under taxonomy',
'numberposts' => -1
);
echo $num = count( get_posts( $args ) );
For instance, if you had a custom taxonomy called “product_category” and wanted to only show posts from the “manes” product_category you would use the below code.
$args = array(
'post_type' => 'product',
'post_status' => 'published',
'product_category' => 'manes',
'numberposts' => -1
);
echo $num = count( get_posts( $args ) );
Source: https://dynamicweblab.com/blog/2013/10/31/get-custom-post-count-custom-taxonomy/

Leave a Reply
Want to join the discussion?Feel free to contribute!