Skip to content

Instantly share code, notes, and snippets.

@ibndawood
Created January 30, 2019 08:37
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ibndawood/105fbb4797bc1e10395bf1bd105e0f0c to your computer and use it in GitHub Desktop.
Save ibndawood/105fbb4797bc1e10395bf1bd105e0f0c to your computer and use it in GitHub Desktop.
Electro v2 - Show brand name in product loop
add_action( 'woocommerce_shop_loop_item_title', 'ec_template_loop_product_brand', 41 );
function ec_template_loop_product_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_name = '';
if ( $terms && ! is_wp_error( $terms ) ) {
foreach ( $terms as $term ) {
$brand_name .= $term->name ;
}
}
if ( ! empty( $brand_name ) ) : ?>
<div class="brand">
<?php echo wp_kses_post( $brand_name ); ?>
</div>
<?php endif;
}
@Bocsek
Copy link

Bocsek commented Feb 23, 2021

Hi!
Is it possible to put brand image (assigned to attribute value) instead of brand name?

@ibndawood
Copy link
Author

Hello again,

Showing brand image is the default functionality. The above code is to override that and display only the name.

@Bocsek
Copy link

Bocsek commented Feb 24, 2021

I'm using Home v4 with Header v5, and in product loop the brand image is not shown by default. (only on single product page) Now I was looking for such settings, but didn't found.
Without the code above: https://paste.pics/e30fde720add006c5e2d6750731abd5a
With the code above: https://paste.pics/37508b18a437a00bdc81f393c709ed20

@ibndawood
Copy link
Author

@Bocsek
Copy link

Bocsek commented Feb 24, 2021

Thanks for your help, I've just emailed the support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment