Reputation: 373
I've got a metafield assigned to pages in my theme and it's the File (List) type. There are 84 items in that list, but Shopify is only returning 50. I figure there is some sort of default limit, but can't find any documentation on how to return all items or at least paginate through them.
A simple version of the Liquid I'm using in the template that returns 50 of the 84 items is
{% assign file = page.metafields.custom.collection_images.value %}
{% for field in file %}
<p>
{{ field }}
</p>
{% endfor %}
If I try and count the items in the list using {{file.count}}
, it actually returns the count as 84, like so
{% assign file = page.metafields.custom.collection_images.value %}
<p>{{ file.count }}</p>
{% for field in file %}
<p>
{{ field }}
</p>
{% endfor %}
Is there a way to get all 84 items to render in the for loop?
Upvotes: 0
Views: 216
Reputation: 11427
That a look at using the paginate aspect of resources. Any time you wrap a resource with a default of 50 items in paginate you should be able to uncork the pages of items that are not returned by default. If it does not work for metafields, then try a different technique I guess. For example to store 84 things in a list, you can use JSON as a replacement? Not ideal but might work, as it all depends on your use case for the list.
Upvotes: 0