Created
March 15, 2013 08:33
-
-
Save kloon/5168340 to your computer and use it in GitHub Desktop.
WooCommerce display brand image on single product page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'woocommerce_before_single_product', 'wc_brand_image_single_product' ); | |
function wc_brand_image_single_product() { | |
global $post; | |
$brands = wp_get_post_terms( $post->ID, 'product_brand' ); | |
if ( $brands ) | |
$brand = $brands[0]; | |
if ( ! empty( $brand ) ) { | |
$thumbnail = get_brand_thumbnail_url( $brand->term_id ); | |
$url = get_term_link( $brand->slug, 'product_brand' ); | |
echo '<a href="' . $url . '"><img class="woocommerce-brand-image-single" src="'. $thumbnail . '"/></a>'; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello buddy,
thanks for sharing, can you please help me to add the product brand on the product view on home page for each product
Like this screenshot. https://prnt.sc/r1MuzsskJUqy
Thanks.