In my WordPress v5.8.1, I have the below query in taxonomy.php to get the list of posts.
$args = array(
'post_type' => array('song', 'dance'),
'post_status' => 'publish',
'posts_per_page' => 10,
);
query_posts($args);
The query return posts from both post_type's.
I would like to create a menu in the same page, where I want to check if the query results has found posts from a specific post_type. The menu looks something like this.
This taxonomy has posts from Song, Dance (if found posts from both post_type's), or
This taxonomy has posts from Song (if found posts from Song post_type only)
Have tried the below within the loop:
$song_count = wp_posts_count('song')->found_posts;
$dance_count = wp_posts_count('dance')->found_posts;
if ($song_count=>0 {
/** code goes here **/
}
Above is returning the count from entire WordPress, not just from current taxonomy.