Home Forums WoodMart support forum Brand name

Brand name

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #53965

    Stanley Black
    Participant

    Hello,

    I want to display brand name above product title on category page(screenshot.png).

    File path is wp-content\themes\woodmart\woocommerce\content-product-base.php

    What doing this line?

    <?php woodmart_product_brands_links(); ?>

    Can I use this line to display brand name above product title?

    Best regards

    Attachments:
    You must be logged in to view attached files.
    #53982

    Artem Temos
    Keymaster

    Hi,

    You can enable this option in Theme Settings -> Shop -> Products styles -> Show product brands next to title.

    Regards

    #54098

    Stanley Black
    Participant

    Thanks for your response!

    Brand name have shop filter url(shop/?filter_brand=alessi) but I need brand page url(brand/alessi/).

    You provide me solution for same problem on product page for brand image(https://xtemos.com/forums/topic/html-blocks-on-brand-page/).
    Can you do the same thing on category page for brand name?

    Kind regards

    #54127

    Artem Temos
    Keymaster

    Try to add the following PHP code snippet to the child theme functions.php file to do this

    	function woodmart_product_brands_links() {
    		global $product;
    		$brand_option = woodmart_get_opt( 'brands_attribute' );
    		$brands = wc_get_product_terms( $product->get_id(), $brand_option, array( 'fields' => 'all' ) );
    
    		if( !woodmart_get_opt( 'brands_under_title' ) || empty( $brands ) ) return;
    
    		$link = ( defined( 'SHOP_IS_ON_FRONT' ) ) ? home_url() : get_post_type_archive_link( 'product' );
    
    		echo '<div class="woodmart-product-brands-links">';
    
    		foreach ( $brands as $brand ) {
    			$filter_name = 'filter_' . sanitize_title( str_replace( 'pa_', '', $brand_option ) );
    			$attr_link = get_term_link( $brand->term_id, $brand->taxonomy );
    			$sep = ', ';
    			if ( end( $brands ) == $brand ) $sep = '';
    
    			echo '<a href="' . esc_url( $attr_link ) . '">' . $brand->name . '</a>' . $sep;
    		}
    
    		echo '</div>';
    	}
    #54140

    Stanley Black
    Participant

    Thank you, perfect!

Viewing 5 posts - 1 through 5 (of 5 total)

The topic ‘Brand name’ is closed to new replies.