Brands - by TheOne - on WordPress WooCommerce support

This topic has 2 replies, 2 voices, and was last updated 4 years, 9 months ago ago by Olga Barlow

  • Avatar: TheOne
    TheOne
    Participant
    July 9, 2019 at 09:07

    Hello,

    Is there a way i can display brands name and not the category name bellow the product images on shop/archive page ?

    Thank you,

    1 Answer
    Avatar: Olga Barlow
    Olga Barlow
    Support staff
    July 9, 2019 at 14:16

    Hello,

    Add the following code to child theme functions.php

    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
        }
    }

    To disable categories go to Theme Options > Product Page layout > Show product category > Off.

    Regards

  • Viewing 2 results - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.Log in/Sign up

We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.