I have a Purfume product with these attributes:
Mint Apple Orange Lavander
And in the product page, inside the additional informations tab, they are displayed on the same line, separated by a comma.
Mint, Apple, Orange, Lavander
I know it’s possible to do a character replacement so that a “,” in the backend becomes a line break <br/>
. But I don’t know how.
I want it to look like this
Mint Apple Orange Lavander
Advertisement
Answer
You can use the woocommerce_attribute
filter to change the commas into line breaks.
add_filter( 'woocommerce_attribute', 'woocommerce_product_attributes_add_line_break', 10, 3 ); function woocommerce_product_attributes_add_line_break( $attribute_list, $attribute, $values ) { if ( !is_product() ) return; //Only on product page $attribute_list = wpautop( wptexturize( implode( '<br>', $values ) ) ); return $attribute_list; }