Created
September 24, 2018 08:17
-
-
Save akther80/7c363454cc8bc73a01d054d0a95b53f2 to your computer and use it in GitHub Desktop.
Electro display brand text instead of brand logo in single product 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
if ( ! function_exists( 'electro_template_single_brand' ) ) { | |
/** | |
* | |
*/ | |
function electro_template_single_brand() { | |
global $product; | |
$product_id = electro_wc_get_product_id( $product ); | |
$brands_tax = electro_get_brands_taxonomy(); | |
$terms = get_the_terms( $product_id, $brands_tax ); | |
$brand_img = ''; | |
if ( $terms && ! is_wp_error( $terms ) ) { | |
foreach ( $terms as $term ) { | |
$thumbnail_id = get_woocommerce_term_meta( $term->term_id, 'thumbnail_id', true ); | |
$brand_img .= '<a href="' . esc_url( get_term_link( $term ) ). '"><span>' . esc_attr( $term->name ) . '</span>'; | |
} | |
} | |
if ( ! empty( $brand_img ) ) : ?> | |
<div class="brand"> | |
<?php echo wp_kses_post( $brand_img ); ?> | |
</div> | |
<?php endif; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment