05
/Nov
How to add infinite scroll pagination/ Load more pagination to Shopify collection pages
Demo: https://www.madamefancypants.com/collections/designers
If your store has lots of products for a specific collection page on your Shopify store? Instead of getting customers to navigate to multiple pages of products you can now add infinite scroll to your Shopify collections pages so customers can keep scrolling through.
- From your Shopify admin, to to Online Store > Theme.
- Find the theme you want to edit and then click Action > Edit code.
- In the Layout section, click theme.liquid to open the file in the online code editor.
- Find
</head>
and paste the below code just above it.
{% if template contains 'collection' %}{{ 'https://cdn.shopify.com/s/files/1/0382/4185/files/ajaxinate.js?937' | script_tag }}{% endif %} - Save.
- In the online code editor of collection page find to the loop
{% for product in collection.products %}
and add more a DIV tag to wrapper and add more a DIV tag just below it. For example12345678910<div id="Huratips-Loop" >{% for product in collection.products %}{% include 'product-grid-item' %}{% endfor %}</div><div id="Huratips-Pagination">{% if paginate.next %}<a href="{{ paginate.next.url }}">Loading More</a>{% endif %}</div> - Add the javascript code to the end of the file.
12345678<script>document.addEventListener("DOMContentLoaded", function() {var endlessScroll = new Ajaxinate({container: '#Huratips-Loop',pagination: '#Huratips-Pagination'});});</script>
- Save
- You are done!
Post a Comment!