This simple snippet displays the brand logo as a small overlay on product images in shop and category pages. The brand logo appears in the bottom-left corner of each product image, making it easy for customers to identify the brand at a glance.
What does this code do?
Gets the product’s brand from the product_brand taxonomy
Retrieves the brand’s thumbnail image
Displays the brand logo as an overlay on the product image
Positions the logo in the bottom-left corner with nice styling
Adds hover effect for better user interaction
Perfect for:
Multi-brand stores
Fashion and clothing sites
Electronics stores
Marketplaces with multiple vendors
Any store that wants to highlight brands
Building brand recognition
The logo overlay is small and unobtrusive but clearly visible, helping customers quickly identify brands while browsing products.
Snippet Instructions
QUICK START:
Make sure you have the product_brand taxonomy active in WooCommerce
Add brand images to your brands (wp-admin/edit-tags.php?taxonomy=product_brand)
Copy and paste the code into your theme’s functions.php file
Go to your shop or category page – brand logos will appear on products!
TO CHANGE LOGO SIZE:
Line 44: Change the width and height values
.tpsc-brand-overlay img {
width: 50px; /* Change size */
height: 50px; /* Change size */
}
TO CHANGE LOGO POSITION:
Lines 35-36: Change the position values
bottom: 5px; /* Distance from bottom */
right: 10px; /* Change to right corner */
/**
* Add brand logo overlay on product images in category/shop pages
* Shows brand logo on bottom-left corner of product image
* Prefix: tpsc_ (TP Snippet Collection)
*/
// Add brand logo overlay to product images
add_action('woocommerce_before_shop_loop_item_title', 'tpsc_add_brand_logo_overlay', 15);
function tpsc_add_brand_logo_overlay() {
global $product;
// Get product brands
$brands = wp_get_post_terms($product->get_id(), 'product_brand');
if (!empty($brands) && !is_wp_error($brands)) {
$brand = $brands[0]; // Get first brand
// Get brand image
$brand_image_id = get_term_meta($brand->term_id, 'thumbnail_id', true);
if ($brand_image_id) {
$brand_image = wp_get_attachment_image_src($brand_image_id, 'thumbnail');
if ($brand_image) {
echo '<div class="tpsc-brand-overlay">';
echo '<img src="' . esc_url($brand_image[0]) . '" alt="' . esc_attr($brand->name) . '" title="' . esc_attr($brand->name) . '">';
echo '</div>';
}
}
}
}
// Add CSS for brand overlay positioning
add_action('wp_head', 'tpsc_brand_overlay_styles');
function tpsc_brand_overlay_styles() {
if (is_shop() || is_product_category() || is_product_tag()) {
?>
<style>
.woocommerce ul.products li.product,
.wc-block-product-template__responsive>li {
position: relative;
}
.tpsc-brand-overlay {
position: absolute;
top: 10px;
left: 10px;
z-index: 10;
background: rgba(255, 255, 255, 0.9);
border-radius: 3px;
padding: 2px;
box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.tpsc-brand-overlay img {
width: 40px;
height: 40px;
object-fit: contain;
display: block;
}
/* Hover effect */
.woocommerce ul.products li.product:hover .tpsc-brand-overlay {
background: rgba(255, 255, 255, 1);
transform: scale(1.1);
transition: all 0.2s ease;
}
</style>
<?php
}
}