Blog Post Pagination

kbarhoover
Participant

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?

0 Upvotes
1 Reply 1
edjusten
HubSpot Employee

Hi @kbarhoover Apologies that no one has reached back to you on this. 

 

Are you still experiencing the pagination issue? If so, please let me know and provide a link to your blog for further troubelshooting. I'll be happy to look into it. 

 

Ed 

 

INBOUND 2017 is just around the corner. Find out more at inbound.com or check out the post on the main Community page and check out the upcoming AMA with Deb Calvert.


Did my post help answer your query? Help the Community by marking it as a solution
0 Upvotes