I'm developing a plugin for Woocommerce and I use the <a href="https://wordpress.org/plugins/taxonomy-images/" rel="nofollow noreferrer">Taxonomy Images</a> plugin to add image feature for Woocommerce product tag custom taxonomy.
Now I am trying to show for each product the product tag name with his coresponding image in a function. But may be I failed something because I see all tags and not only the tags for a specific product.
To get the product ID I have tried with
but it's not working.
This is my code:
Any help is appreciated.
Now I am trying to show for each product the product tag name with his coresponding image in a function. But may be I failed something because I see all tags and not only the tags for a specific product.
To get the product ID I have tried with
Code:
global $product;
This is my code:
Code:
function woo_idoneo_tab_content() {
$id = get_the_ID();
$terms = apply_filters( 'taxonomy-images-get-terms', '', array('taxonomy' => 'product_tag', 'id' => $id, ) );
if ( ! empty( $terms ) ) {
print '<div class="container">';
foreach ( (array) $terms as $term) {
$url = get_term_link ($term->slug, 'product_tag' , $id);
print '<div class="col-xs-12 col-sm-6 col-md-6 col-lg-4">';
print '<div class="card">';
print '<div class="card-img-top"><a href="'.$url.'">' . wp_get_attachment_image( $term->image_id, 'medium' ) . '</a></div>';
print '<div class="card-body">';
print "<h5 class='card-title'><a class='btn btn-primary' href='{$url}'>{$term->name}</a></h5>";
}
print '</div>';
print '</div>';
print '</div>';
}
print '</div>';
}
}
Any help is appreciated.