Skip to content

Instantly share code, notes, and snippets.

@kloon
Created March 15, 2013 08:33
Show Gist options
  • Save kloon/5168340 to your computer and use it in GitHub Desktop.
Save kloon/5168340 to your computer and use it in GitHub Desktop.
WooCommerce display brand image on single product page
<?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>';
}
}
?>
@mohmimi
Copy link

mohmimi commented Jul 30, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment