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

SOLUTION <?php $args = array( ‘post_type’ => ‘product’, ‘post_status’=>’publish’, ‘tax_query’ => array( ‘relation’ => ‘AND’, array( ‘taxonomy’ => ‘sectors’, ‘field’ => ‘slug’, ‘terms’ => ‘garden’, ), array( ‘taxonomy’ => ‘season’, ‘field’ => ‘slug’, ‘terms’ => ‘winter’, ), ), ); $query = new WP_Query( $args ); echo $query->post_count ; ?>

How to add a shortcode function that returns the taxonomy slug of the actual post within the loop

get_the_terms() will always return an array; but because you have only one ‘project_category’, you can simply use its first element: add_shortcode( ‘return_taxonomy_slug’, ‘my_shortcode_return_taxonomy_slug’ ); function my_shortcode_return_taxonomy_slug() { $terms = get_the_terms( get_the_ID(), ‘project_category’); return $terms[0]->slug; }

wp_set_object_terms doesn’t work

This is the solution function add_tags_products() { global $product; $args = array( ‘post_type’ => ‘product’, // your product post type ‘posts_per_page’ => – 1, ); $posts = get_posts($args); foreach ($posts as $post): setup_postdata($post); // check to see if the post has any tags if( ! has_term( ”, ‘product_tag’, $post->ID ) ) : // create the … Read more