To continue receiving payouts, you need to secure your account by turning on two-step authentication. If two-step authentication is not turned on your payouts will be paused. Learn more

Filtering collections (not product)

begginer1231
Excursionist
17 0 1

Is it even possible to paginate filtered collections as below?

 

{%- liquid

assign filtered_collection = collections | where: collections.metafields.custom.x, 'foo'

-%}

{%- paginate filtered_collection by xyz -%}

something

{%- endpaginate -%}

 

I tried as above but this returns, 'filtered_collection' is not paintable.

Wondering if Shopify/liquid can paginate filtered collections

 

I am interested in this topic because I want to make sure the pagination number is correct and the items displayed on the page are correct. 

Reply 1 (1)
Ujjaval
Shopify Partner
603 101 78

@begginer1231 
Follow below step for pagination :

  1. Place the following code where you wish pagination to display. This code must appear within paginate tags for the following example to work. Within the paginate tags, you can access the paginate object.
  2. Specify the type of content you want to paginate, and at what limit you wish to paginate by, for example {% paginate collection.products by 12 %}.
  3. Override the| default_pagination filter Next » and « Previous labels by passing a new label to the next and previous options.

 

{%- paginate blog.articles by 5 -%}
  {%- for product in collection.products -%}
    <!-- show product details here -->
  {%- endfor -%}

  {{ paginate | default_pagination: next: 'Older', previous: 'Newer' }}
{%- endpaginate -%}​