Solution:
The conditional is_product_tag()
will not work to get a product that has a product tag, as it’s used to return true when viewing a product tag archive page.
To do achieve what you want to do you need to use WordPress has_term()
conditional function with defined $taxonomy argument to 'product_tag'
, this way:
// Define BELOW your product tag ID, slug or name (or an array of values)
$term = 'adexample1';
$term2 = 'adexample2'; // ...
// HERE are your conditions with your code
if( has_term( $term, 'product_tag' ) ){
echo "test1";
} elseif( has_term( $term2, 'product_tag' ) ){
echo "test1";
} else {
echo "<p>test6</p>";
}
This should work as it works for product categories with defined $taxonomy argument to 'product_cat'
…