How to Set up Multiline Text with Metafields?

Hi, I want to add line breaks in this text and was advised to do it through metafields but I am unsure of how to set this up.

For example I’d like the line breaks as seen in the text box on the left to show on the actual webpage. How do I set up metafields to do this?

Thanks in advance.

This is the webpage: https://lunanectar.com/collections/shop-hair/products/mars-sand-volumizing-adaptogenic-dry-shampoo

1 Like

Hi there,

You can add spaces through custom CSS or by using
element between paragraphs.

Let me know if this addressed your issue.

Cheers!

The
doesn’t work in this case. Looking to set up multiline text metafields!

Hi @ln3635

I believe your theme is filtering the richtext with escape. I do agree with the suggestion to do this using metafield. Since every product has different ingredients. You can follow the instructions below on how to use metafield for this.

  1. From your Admin Page, click Settings in your left hand bottom corner

  2. Go to metafields, and add Product metafields.

  3. Follow the exact settings in the image below

  1. You should be able to enter the information in your product. Go to your product, and assign each paragraph as a line of item. Add items as many as you want. Please see image below. Make sure to click SAVE

Enter the information sentence by sentence

Go to your theme editor:

  1. From your Admin Page, click Online Store > Themes >Customize
  2. Open the product page, and add a custom liquid block
  3. In the space provided copy / paste the code below. Make sure to SAVE
{% for ingredients in product.metafields.custom.ingredients.value %}
{% assign ingredient = ingredients | split: ":" %}
**{{ ingredient[0] }}** {{ ingredient[1] }}{% unless forloop.last %}

{% endunless %}
{% endfor %}
1 Like

This is a great solution!

HI Made4Uo!

In which part of the liquid under Edit Codes, should I add these codes. I am not able to follow the Theme editor explanation. Can you kindly provide it detail?

I am trying to add a details in product description as shown below.

Regards

Bharanidar K

Depending on your theme. If you have an option to have custom block under the product template, I would suggest using it. Otherwise, you might need to hire someone to read and add the code for you