Reply 252094 to: Xml feed and print text values

Avatar: Olga Barlow
Olga Barlow
Support staff
September 21, 2020 at 15:48

Hello,

Sorry for the delay in answering.

Try the following code to register [et_single_product_brand_names] shortcode

add_shortcode( 'et_single_product_brand_names', 'et_single_product_brand_names' );
if ( ! function_exists( 'et_single_product_brand_names' ) ) {
    function et_single_product_brand_names( $atts = array() ) {
        $product_id = get_the_ID();
	    $terms = wp_get_post_terms( $product_id, 'brand' );
	    $brand = etheme_get_option( 'brand_title' );

	    if ( count( $terms ) < 1 ) {
		    return;
	    }
	    $_i = 0;

	    $brand_titles = '';

	     foreach ( $terms as $brand ) { $_i ++;
	     	$brand_titles .= esc_html( $brand->name );
			if ( count( $terms ) > $_i ) {
				$brand_titles .= ", ";
			}
		}
     	return $brand_titles;
    }
}

Regards

Go To The Whole Conversation In Topic
We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.