This topic has been ask in Stackexchange many times. But most of question unanswered or has incomplete answer. My custom post type "Product" and two different taxonomy "Sectors" and "Seasons". Now I want to display product count for Garden archive page ( garden is the term of sectors taxonomy) that have realtion with Winter ( winter is the term of seasons taxonomy). I did all my best during these 3 days but I can not solve this problem. Please help me. thanks for your attention. This is also a good source but can make it works https://wordpress.stackexchange.com/a/327150/196375
$sectors = get_queried_object();
$season = get_terms( array(
'taxonomy' => 'seasons',
'hide_empty' => true,
'fields' => '58', // winter term id
) );
foreach ($current_taxs as $current_tax) {
foreach ($seasons as $seasons) {
$args = array(
'post_type' => 'product',
'post_status'=>'publish',
'tax_query' => array(
'relation' => 'AND',
array(
'taxonomy' => $current_tax,
'field' => 'slug',
'terms' => array( $current_tax ),
),
array(
'taxonomy' => 'season',
'field' => 'slug',
'terms' => array( $season ),
),
),
);
$query = new WP_Query( $args );
echo $query->post_count;
}
}