I was managed to add “Brand name” to the category view list in the spot between image and category name (or product name). The code I have used is below.
The problem:
- How can I remove the link from the brand (href part), so it is not clickable? Only product title should be clickable to open product details.
- How can I apply a style to the Brand value? Ideally I want to use
same style/color used for the category label in the category view.
The code:
function pwb_show_brands_in_loop(){
global $product;
$product_id = $product->id;
$product_brands = wp_get_post_terms($product_id, 'pwb-brand');
if(!empty($product_brands)){
echo '<div class="custom-loop-brands">';
foreach ($product_brands as $brand) {
echo '<a href="'.get_term_link($brand->term_id).'">'.$brand->name.'</a>';
}
echo '</div>';
}
}
add_action(‘woocommerce_before_shop_loop_item_title’, ‘pwb_show_brands_in_loop’,1);