I have already tried this code:
$cats = get_terms('category');
$counts_by_term = wp_list_pluck( $cats, 'count', 'slug' );
echo $counts_by_term['uncategorized'];
But the problem is that, the category taxonomy is shared to every post type.
Situation:
I have a CPT called Testimonials and enabled the category and created a single post there with uncategorized category.
I also have 5 posts in post post type, all have uncategorized category assigned to them.
Now, I just want to get the number of posts with uncategorized category only from Testimonials post type.
The code above will output: 6
Which should only be: 1
3
Answers
here’s my solutions,
//This would run with less stress to your Database