I am using woocommerce on my wordpress site.
My problem is that when adding a custom product attribute for a simple product, I want to add a multi line attribute value.
When I enter a line break through enter key it shows in the attribute editor but all the lines are appended together in the main product page.
I have tried each and every code for a new line

and even url encoding %0A but nothing seems to work.
In all cases i get all appended lines.
For Example what i want to show is
- Machined to close tolerances to meet interchangeability.
- Harden and tempered to ensure increased life-cycle.
- Blackened and coated with rust preventive oil.
But what it shows in the front end is
- Machined to close tolerances to meet interchangeability. 2. Harden and tempered to ensure increased life-cycle. 3. Blackened and coated with rust preventive oil.
Thanks in advance..
Product attributes are “sanitized” before they are added to the database, all html tags are stripped.
You can always pick a custom phrase to indicate where a new line is needed, then use
str_replace()
in your product_attributes.php to convert the custom phrase to a<br>
tag beforeecho
ing the string.If you want “an apply to all rule” of how values of product attributes are displayed in the frontend, then you should look into the $glue of
implode()
function.In HTML we use
<br>
to show data in multi line. Instead of using, you can use
**<br>**
OR**<br>**
to show data in multi line. But this a one time solution as once you save it wordpress converts**<br>**
totag and when update your post second time, wordpress will remove new line pattern.
If you are not going to update the post or you can add above pattern each time when you update then you can use this answer.