- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
Blog Post Pagination
Aug 9, 2017 12:12 PM
I have the following code that displays on my post pages:
<!--Post Pagination Start-->
<div class="list-pagination">
{% if content.next_post_slug %}
<a class="pagination-btn list-prev-post" style="color: #ffffff;" href="/{{ content.next_post_slug }}">Previous</a>
{% endif %}
{% if content.previous_post_slug %}
<a class="pagination-btn list-next-post" style="color: #ffffff;" href="/{{ content.previous_post_slug }}">Next</a>
{% endif %}
</div>
<!--Post Pagination End-->
This code allows visitors to browse forward and backward through posts. It works perfectly for published posts.
When I create a new post, it seems that the code loses a point of reference as to what was previous and what is next and does not display the pagination. Instead, the following is rendered:
<!--Post Pagination Start-->
<div class="list-pagination">
</div>
<!--Post Pagination End-->
If I remove the pagination code from the template, save/publish the template and then go back in and re-add the pagination code, save/publish...my newly created post will have the paginiation as expected.
Will I just have to remove/add the code every time I publish a new post...or is there something in the code that can be updated to prevent this behavior?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content