I have used other forum posts to work out the JS for adding a Previous and Next link on my blog posts.
I have added headings too, using other code from previous posts.
BUT I get 2 copies of the heading.
I don’t understand the JS - I just cut and pasted and changed things as required, but obviously there’s something not right here.
Here’s the code I’m using:
<style>#post_list{display: none;}</style>
<script>
var Webflow = Webflow || [];
Webflow.push(function () {
var next_href = $('#post_list .w--current').parent().next().find('a').attr('href');
var previous_href = $('#post_list .w--current').parent().prev().find('a').attr('href');
var next_title = $('#post_list .w--current').parent().next().find('a').text();
var previous_title = $('#post_list .w--current').parent().prev().find('a').text();
//if last post in list
if(next_href == undefined) {
next_href = $('#post_list').children().children().first().find('a').attr('href');
$('#next_button').fadeOut(); //optional - remove if you want to loop to beginning
}
//if first post in list
if(previous_href == undefined) {
previous_href = $('#post_list').children().children().last().find('a').attr('href');
$('#previous_button').fadeOut(); //optional - remove if you want to loop to end
}
//apply hrefs to next / previous buttons
$('#next_button').attr('href', next_href);
$('#previous_button').attr('href', previous_href);
$('#next_title').text(next_title);
$('#previous_title').text(previous_title);
});
</script>
I guess the problem is in the 3rd “paragraph” ???
Here is my public share link: https://preview.webflow.com/preview/jessicas-fabulous-project-570f5e?utm_medium=preview_link&utm_source=designer&utm_content=jessicas-fabulous-project-570f5e&preview=b16a4c3780f1ad56fb149556d01d0b21&pageId=5edfb2299d4d57681fa48c8b&itemId=5edfb235a5e96662188f3258&mode=preview
(how to access public share link)