Skip to content

Instantly share code, notes, and snippets.

@farookibrahim
Created December 7, 2017 05:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save farookibrahim/4de695c171bb82197583c3d1b78e51ee to your computer and use it in GitHub Desktop.
Save farookibrahim/4de695c171bb82197583c3d1b78e51ee to your computer and use it in GitHub Desktop.
Electro Display Brands Logo in Brands Archive Page
function el_display_brand_thumbnail_in_archive() {
$brand_taxonomy = electro_get_brands_taxonomy();
if ( ! is_tax( $brand_taxonomy ) ) {
return;
}
if ( ! get_query_var( 'term' ) ) {
return;
}
$term = get_term_by( 'slug', get_query_var( 'term' ), $brand_taxonomy );
$thumbnail_id = get_woocommerce_term_meta( $term->term_id, 'thumbnail_id', true );
if ( $thumbnail_id ) {
$image_attributes = wp_get_attachment_image_src( $thumbnail_id, 'full' );
if( $image_attributes ) {
echo '<div class="brand-logo"><img src="' . esc_url( $image_attributes[0] ) . '" alt="' . esc_attr( $term->name ) . '" /></div>';
}
}
}
add_action( 'woocommerce_before_shop_loop', 'el_display_brand_thumbnail_in_archive', 9 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment