As the title says I’m looking for a shortcode I can use to show the tag of a specific product. All my products have only one product tag set for each.
For example, if the product with ID: 1250 has the tag “Horse” I need the way to put a shortcode specifying the ID of the product and show your respective tag. In the example the shortcode should show on the screen the word “Horse”
Tyring to modify the following code to achieve it:
$terms = wp_get_post_terms( get_the_id(), 'product_tag' );
if( count($terms) > 0 ){
foreach($terms as $term){
$term_id = $term->term_id; // Product tag Id
$term_name = $term->name; // Product tag Name
$term_slug = $term->slug; // Product tag slug
$term_link = get_term_link( $term, 'product_tag' );
$output[] = '.$term_name.';
}
$output = implode( ', ', $output );
echo $output;
}
But I don't have the enough knowledge to achieve it
Any help is appreciated.