This topic has 8 replies, 3 voices, and was last updated 5 years, 3 months ago ago by Olga Barlow
Hello,
Is there a way i can display brands name and not the category name (becouse there are more categories and it gets crowded) bellow the product images on shop/archive page ?
Thank you,
Hello,
You can disable categories from the shop grid via Theme Options > WooCommerce (Shop) > Shop > Products style > Product Content Elements > http://prntscr.com/p1jx2y
Or you can set “Primary category” that will be shown on the grid – http://prntscr.com/p1jxr2
To display brands you can add this code in functions.php file of the child theme:
add_action('woocommerce_after_shop_loop_item_title', 'et_print_brands', 10);
function et_print_brands(){
global $post, $product;
$terms = wp_get_post_terms( $post->ID, 'brand' );
if(count($terms)>0) {
?>
<p>Brands:
<?php
foreach($terms as $brand) {
$image = '';
$thumbnail_id = absint( get_term_meta ( $brand->term_id, 'thumbnail_id', true ) );
?>
<a href="<?php echo get_term_link($brand); ?>">
<?php
echo $brand->name;
?>
</a>
<?php
}
?>
</p>
<?php
}
}
Regards
Hello,
Thank you for a quick response! But unfortunately the brand labels are not showing.
Hello,
Is child theme activated on your site?
Have you cleared all cache?
Regards
Hello,
Yes it’s activated and i cleared all the cache. I also tried to put it original functions.php (for test) and it returns -> “The site is experiencing technical difficulties.”
Hello,
If you got that message it means that some fatal error appeared on your site, probably you missed something in code. What code the original functions.php includes? Provide screenshot.
Besides, if you go to XStore > Theme Options > WooCommerce > Shop elements > Brand there is option to enable brand on grid/list http://prntscr.com/p1vgxl
Is not that position suitable for you without that additional code?
Regards
This is beyond stupid on my part… offcourse nothing works if you don’t assign the product to the brand. Rose your code worked perfectly! And Olga i didn’t know you could enable the brands in the theme options. Those two solutions are enough.
Sorry for the inconvenience
Hello,
Glad that you sorted out. You are welcome.
Regards
You must be logged in to reply to this topic.Log in/Sign up