custom post types – Display tags cloud of current taxonomy term in archive page

Question

I am so sorry that I have no my own code for you because I am not good at php. I am trying to display tags ( with custom post count ) of current custom taxonomy term. It because I will display tags that have been used in the posts this taxonomy term. if any tag that has not been used in posts of this taxonomy term then don’t display. But my tags is also a custom taxonomy ( I don’t use wordpress default tags). Can you help me please. Thanks for your attention. I am trying to do according this answer. But not succeed yet. Some smililar questions:

Count number of posts which exist in 2 taxonomies?

WordPress – Only show tags under the current Category

Display tags cloud from a specific category ID with a shortcode

$currenttax = get_queried_object();
$mytag = get_terms( array(
    'taxonomy' => 'custom-tag',
    'hide_empty' => false,
    'fields' => 'id=>slug' 
) );

$mytax = get_terms( array(
    'taxonomy' => 'my-custom-taxonomy',
    'hide_empty' => false,
    'fields' => 'id=>slug' 
) );


foreach ($mytaxs as $mytax) {

foreach ($mytags as $mytag) {

$args = array(
    'post_type' => 'my-post-type',
 'post_status'=>'publish',
    'tax_query' => array(
        'relation' => 'AND',
        array(
            'taxonomy' => 'my-custom-taxonomy',
            'field'    => 'slug',
            'terms'    => array( $currenttax ),
        ),
        array(
            'taxonomy' => 'mytag',
            'field'    => 'slug',
            'terms'    => array( $mytag ),
        ),
    ),
);
$query = new WP_Query( $args );

echo $mytag .": " . $mytax . ": " . $query->post_count . "<br>";

}
}

0
Gidromasservis QSC 2 months 2021-04-10T01:13:18-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse