Skip to main content
added 102 characters in body
Source Link

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;

}
}

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

$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;

}
}

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;

}
}
deleted 14 characters in body
Source Link

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

$current_tax$sectors = get_queried_object();

$season = get_terms( array(
    'taxonomy' => 'MY-SECOND-TAXONOMY''seasons',
    'hide_empty' => true,
    'fields' =>  'id=>slug''58', // winter term id
) );


foreach ($current_taxa$current_taxs as $current_tax) {

foreach ($seasons as $seasons) {

$args = array(
    'post_type' => 'MY-CUSTOM-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;

}
}

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

$current_tax = get_queried_object();

$season = get_terms( array(
    'taxonomy' => 'MY-SECOND-TAXONOMY',
    'hide_empty' => true,
    'fields' =>  'id=>slug'
) );


foreach ($current_taxa as $current_tax) {

foreach ($seasons as $seasons) {

$args = array(
    'post_type' => 'MY-CUSTOM-POST-TYPE',
 '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;

}
}

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

$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;

}
}
Source Link

display post count in archive page that have relation with another taxonomy term

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

$current_tax = get_queried_object();

$season = get_terms( array(
    'taxonomy' => 'MY-SECOND-TAXONOMY',
    'hide_empty' => true,
    'fields' =>  'id=>slug'
) );


foreach ($current_taxa as $current_tax) {

foreach ($seasons as $seasons) {

$args = array(
    'post_type' => 'MY-CUSTOM-POST-TYPE',
 '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;

}
}