Display category image on single product page
-
Hello,
I want to display my category image on the single product page. All of my products are only assigned to one specific category, no products have multiple categories.
This code lets me display the category image for the current category on the category page, but I want to do exactly the same thing on the single product page.
global $wp_query; $cat = $wp_query->get_queried_object(); $thumbnail_id = get_woocommerce_term_meta( $cat->term_id, 'thumbnail_id', true ); $image = wp_get_attachment_url( $thumbnail_id ); if ( $image ) { echo '<img class="absolute category-image" src="' . $image . '" alt="" />'; }
How can I modify this to work on the single product page since, as stated above, none of my products have multiple categories?
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Display category image on single product page’ is closed to new replies.