Adding Line break in woocommerce product attributes

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.

Read More

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

  1. Machined to close tolerances to meet interchangeability.
  2. Harden and tempered to ensure increased life-cycle.
  3. Blackened and coated with rust preventive oil.

But what it shows in the front end is

  1. 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..

Related posts

Leave a Reply

2 comments

  1. 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 before echoing 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.

  2. In HTML we use <br> to show data in multi line. Instead of using
    , you can use **&lt;br&gt;** OR **&#60;br&#62;** to show data in multi line. But this a one time solution as once you save it wordpress converts **&lt;br&gt;** to
    tag 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.