Rendering more than 50 collections using a metafield

Rendering more than 50 collections using a metafield

stressedowner
Shopify Partner
37 1 6

I have a metafield 'subcollection' that accepts a list of collection. On one of the collection pages, I have 124 'subcollections', but it only returns 50. What's the solution or work around for this? 

 <ol>
{% for col in collection.metafields.custom.subcollections.value %} 
{% if col != blank %}
 <li>{{ col.title }}</li>
{% endif %}
{% endfor %}
</ol>
Replies 2 (2)

rifat_ShopiDevs
Shopify Partner
61 6 9

@stressedowner hope you are well,
can you please try with this code

{% assign subcollections = collection.metafields.custom.subcollections.value | split: ',' %}
{% assign page_size = 50 %}
{% assign total_pages = subcollections.size | divided_by: page_size | ceil %}

{% for page in (1..total_pages) %}
  <h3>Page {{ page }}</h3>
  <ol>
    {% assign start_index = page_size | times: page | minus: page_size %}
    {% assign end_index = start_index | plus: page_size %}
    {% assign current_page_subcollections = subcollections | slice: start_index, page_size %}
    {% for col_handle in current_page_subcollections %}
      {% assign col = collections[col_handle] %}
      {% if col %}
        <li>{{ col.title }}</li>
      {% endif %}
    {% endfor %}
  </ol>
{% endfor %}

hope its work for you with paginations 
thank you

Found it helpful? Please like and mark the solution that helped you.
Slider Revolution - Create sliders, theme sections, banners, videos, pages, advanced animation, and social feeds.
Essential Grid Gallery - Create photo galleries, video galleries, portfolio galleries, product gallery, collection gallery and more.
EasyDisplay: Product Showcase - Easily display collections, related products, discounts, recently viewed items, and best sellers
stressedowner
Shopify Partner
37 1 6

It didn't work. 

I tried printing out the values of subcollections and its size.

subcollections value is CollectionDropList
subcollection.size is 1