Skip to content

Instantly share code, notes, and snippets.

@WPprodigy
Last active June 23, 2017 22:36
Show Gist options
  • Save WPprodigy/937774ee0505cd22bbc07079fb741516 to your computer and use it in GitHub Desktop.
Save WPprodigy/937774ee0505cd22bbc07079fb741516 to your computer and use it in GitHub Desktop.
Add Brands image to archives.
add_action( 'woocommerce_archive_description', 'woocommerce_brand_image_custom', 18 );
function woocommerce_brand_image_custom() {
if ( is_tax( 'product_brand' ) ){
global $wp_query;
$category = $wp_query->get_queried_object();
$thumbnail_id = get_woocommerce_term_meta( $category->term_id, 'thumbnail_id', true );
$image = wp_get_attachment_url( $thumbnail_id );
if ( $image ) {
echo '<img src="' . $image . '" alt="' . $category->name . '" />';
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment