-
-
Save ibndawood/4b4e8a60902ee59eef1d1b01354fa511 to your computer and use it in GitHub Desktop.
Electro Display Brands Logo in Brands Archive Page
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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