Skip to content

Instantly share code, notes, and snippets.

@khoipro
Created May 15, 2018 01:08
Show Gist options
  • Select an option

  • Save khoipro/e33dd0e893ef49212c282f69d00d3742 to your computer and use it in GitHub Desktop.

Select an option

Save khoipro/e33dd0e893ef49212c282f69d00d3742 to your computer and use it in GitHub Desktop.
Shopify - Custom Page Pagination
<ul class="pagination__inner relative align-l mv1 pl0 f fw aic">
{% if current_page > 1 %}
{% assign previous_page = current_page | minus:1 %}
<li class="pagination__arrow pagination__arrow--previous mr05 inline-block">
<a href="{{ page.url }}?page={{ previous_page }}" class="inline-block relative" title="Previous">Previous</a>
</li>
{% endif %}
{% for i in (1..total_pages) %}
<li class="pagination__page mh025 inline-block{% if current_page == i %} is-active{% endif %}">
<a href="{{ page.url }}{% if i != 1 %}?page={{ i }}{% endif %}" class="medium inline-block align-c" title="">{{ i }}</a>
</li>
{% endfor %}
{% if current_page < total_pages | minus:1 %}
{% assign next_page = current_page | plus:1 %}
<li class="pagination__arrow pagination__arrow--next ml025 inline-block">
<a href="{{ page.url }}?page={{ next_page }}" class="inline-block relative" title="Next">Next</a>
</li>
{% endif %}
</ul>
{%- assign previous_page = nil %}
{%- assign nex_page = nil -%}
@khoipro
Copy link
Author

khoipro commented May 15, 2018

To use:

{% if total_pages > 1 %}
  {% include 'page-pagination' with total_pges %}
{% endif %}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment