Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
I have created a text metafield list called ingredients and I want to loop through it in liquid.
The problem is when I do {{ product.metafields.info.ingredients }}, it gives me a result
["Lorem Ipsum is simply dummy text of the printing.","Lorem Ipsum 2 is simply dummy text of the printing.","Lorem Ipsum 3 is simply dummy text of the printing.","Lorem Ipsum 4 is simply dummy text of the printing."]
But when I try to loop through it like this
{% for ingredient in product.metafields.info.ingredients %}
<li>{{ ingredient }}</li>
{% endfor %}
It doesn't output anything. Any idea what I am doing wrong? Please help.
Solved it.
I was missing value in the for loop.
The correct syntax is
{% for ingredient in product.metafields.info.ingredients.value %}
<li>{{ ingredient }}</li>
{% endfor %}
YOU SAVED MY NIGHT!!! Thanks 🙂
Thank you! Burnt up an hour trying everything to get the output.
Was missing the .value also
This has totally helped, but now i have another wrinkle. I want each item in the metafield array (which are separated by commas) to link to a search of that item. But what I'm getting is a link to both items. I don't think it is treating my metafield like an array. Is that something i needed to do when defining the metafield?
This is my code:
{% for movieactors in product.metafields.custom.movieactors.value %}
<a href="/search?q={{ movieactors }}" >{{ movieactors }}</a>
{% endfor %}
Thanks in advanced for any help you (or anyone else!) can provide.
Thanksss 🤙
<img src="d">
Hey Community 👋 Did you know that March 15th is National Everything You Think Is W...
By JasonH Apr 1, 2025Discover how to increase the efficiency of commerce operations with Shopify Academy's l...
By Jacqui Mar 26, 2025Shopify and our financial partners regularly review and update verification requiremen...
By Jacqui Mar 14, 2025