Reputation: 251
I want to display brand logos on all product pages.
I've uploaded the logos in the theme editor by going to products->attributes->brands...clicking on the sprocket allows one to upload a thumbnail image.
There are several plugins that can achieve the same thing, but there must be a way to retrieve the information of the brand thumbnail.
Upvotes: 2
Views: 5496
Reputation: 5440
If you're using the WooCommerce Brands plugin, the following code supports obtaining a brand thumbnail URL:
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>';
}
.. If you are looking up via a term ID, then the following code will also obtain the thumbnail URL:
$url = get_brand_thumbnail_url( $term->term_id, 'full' );
Upvotes: 2