Is pagination possible for filtered collections in Shopify Liquid?

Is pagination possible for filtered collections in Shopify Liquid?

begginer1231
Shopify Partner
19 0 2

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
1242 197 213

@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 -%}​