CMS Development


Blog Post Pagination - Endless Loop (Prev/Next)

If I'm on the first post and I want to be able to click "Prev" and get to the last post how would I accomplish this?


Similarly, if I'm on the last post and click "Next" I would like to loop to the first post.


File: blog-post.html

<div class="pagination">
<div class="container">

<ul class="pagination-nav nav">
<li class="nav-item">
<a href="/{{ content.previous_post_slug }}"
class="{% if content.previous_post_slug %} {% else %}disabled {% endif %}nav-link nav-link-prev">Prev</a>
<li class="nav-item">
<a href="{{ group.absolute_url }}" class="nav-link nav-link-all btn btn-primary">
<span>See All Wërk</span>
<li class="nav-item">
<a href="/{{ content.next_post_slug }}"
class="{% if content.next_post_slug %} {% else %}disabled {% endif %}nav-link nav-link-next">Next</a>

0 Replies 0

0 Replies

No replies on this post just yet

No one has replied to this post quite yet. Check back soon to see if someone has a solution, or submit your own reply if you know how to help! Karma is real.

Reply to post

Need help replying? Check out our Community Guidelines