• Hello all,
    Tito,
    after many tries (I’m a php dummy), for those who are looking to display the brand name in single product page as Brand: brand name with a link to the archive page of the brand, here is a code to paste in your functions.php to display the clickable brand name in the single product page.
    The number , 25 ); used in the snippet set the brand name position below the description and before the variation price. If you want to display elsewhere, please refer to the numbers below and choose one in between:
    * woocommerce_single_product_summary hook
    * @hooked woocommerce_template_single_title – 5
    * @hooked woocommerce_template_single_rating – 10
    * @hooked woocommerce_template_single_price – 10
    * @hooked woocommerce_template_single_excerpt – 20
    * @hooked woocommerce_template_single_add_to_cart – 30
    * @hooked woocommerce_template_single_meta – 40
    * @hooked woocommerce_template_single_sharing – 50

    HERE is the code :
    /* —————————————————– */
    /* – PERFECT-brands : display-brand-description – */
    /* – on single product page – */
    /* —————————————————– */

    
    add_action( 'woocommerce_single_product_summary' , 'woocommerce_brand_name', 25 );
    function woocommerce_brand_name() {	
    	global $post;
    		$brands = wp_get_post_terms( $post->ID, 'pwb-brand', array('fields' => 'all') );
    	foreach( $brands as $brand ) {
    		echo '<div class="artist-brand">';
    		echo __( 'Brand', '') . ':&nbsp;' . '<a>term_id).'">'.$brand->name.'</a>';
    		echo '</div>';
    	}
    }
    add_shortcode( 'brand_name', 'woocommerce_brand_name' );
    

    —- you can change echo __( 'Brand', '') by echo __( 'Artist', '') or whatever you use the plugin for, and apparently you can use the shortcode [brand_name] elsewhere you like.
    the brand is displayed in a div with a custom css class name <div class="artist-brand">you can modify according to your style.css file
    Yours, Chris

    • This topic was modified 7 years, 12 months ago by cglaudel.
    • This topic was modified 7 years, 12 months ago by cglaudel.
  • The topic ‘linked brand name in single product page’ is closed to new replies.