Filtering the pagination liquid function

New Member
8 0 0

Does anyone know how to modify the pagination function to include only certain products.

For example let's take the following code:

{% paginate collection.products by 16 %}

If I then want to only include available products by adding

{% unless product.available %}

in the for loop I have the problem that 16 products have already been parsed and now you're cutting them out of the loop, so maybe only 14 will show on that page, even though the pagination will indicate 16. Therefore I need to somehow redefine 'collection.products' in the initial paginate function to paginate only the kind of products i want. Does anyone have an example of this?