I want to display the category image as banner in the woocommerce single product page. I'm using this code, but it shows all the category image.
if(is_single()) {
$terms = get_the_terms( $post->ID, 'product_cat' );
foreach ( $terms as $term ){
$category_name = $term->name;
$category_thumbnail = get_woocommerce_term_meta($term->term_id, 'thumbnail_id', true);
$image = wp_get_attachment_url($category_thumbnail);
echo '<img class="absolute '.$category_name.' category-image" src="'.$image.'">';
}
}
I want only to show the category image. when I click on the product, it shows its category image as banner.