skip to Main Content

I need to get the list of images from my metafield(content type: collection list) in collection. I’m using this logic but it is not working…

Code snippet

{% assign top_collections = collection.metafields.custom.c-top-collections %}
{% if top_collections %}
  <ul>
    {% for collection in top_collections %}
      <li>{{ collection.value }}</li>
    {% endfor %}
  </ul>
{% endif %}

Please, what is the correct form of doing this? Thank you.

2

Answers


  1. Chosen as BEST ANSWER

    Example solution here with some variables being pulled:

    {% assign collection-list = collection.metafields.menu.c-top-collections %}
    
    {% for collection-list-item in collection-list.value -%}
     {% if collection-list != blank %}
      <img class="rounded-full h-28 w-28 object-cover object-center aspect-square   " src="{{ collection-list-item | image_url }}" alt="{{ collection-list-item.image.alt }}"/>
      <h2 class="text-xl mt-4 text-center">{{ collection-list-item.title }}</h2>
     {% endif %}
    {% endfor %}
    

  2. To get your array you need to write this {{ collection.metafields.custom.c-top-collections.value }}

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search