'Next' button on a blog post page

Hello,
I want to put a ‘Next’ button on the bottom of each blog post page, that would take the reader to the next (older) blog article. I’m aware of how to put ‘next’ and ‘previous’ buttons on a dynamic page, but I want to but the button on the blog post page .

What is the correct code snippet for this?

3 Likes

Nobody can provide an answer for this question? I have the exact same need, thank you in advance for any idea.

I am in desperate need for an answer to this!!

I really think that Wix does not allow this function, for some unexplainable reasons.

I really would like this Prev/Next post feature as well!! Pleassseee!!

Hello Ross,

like it seems to be, these were the last customizations/upgrades on Wix-Blog-system…

If you have a wished function which is still not implemented on wix, you can use the WISHLIST…
I do not know if a Wix-Wishlist exists, but perhaps you could get it on CORVID-Wishlist…

https://www.wix.com/corvid/wishlist?page=1

Still no upgrade regarding the Prev/Next post feature… :frowning:

4 years later, still no improvement to this feature request. its a fundamental requirement yet given wix’s reputation, they can’t implement this till date is indeed surprising.

1 Like

Almost 5 years later and still no update for this feature. This shows how unprofessional to not having such feature as a very big website builder and how dissapointing that is. I’m sure thousands of people are waiting for this feature. I hope we can see a better and developed Wix.

Ugh still no improvement?

Chat GPT wrote this but it’s not working:
import wixData from ‘wix-data’;
import wixLocation from ‘wix-location’;

$w.onReady(function () {
let currentSlug = wixLocation.path[1];
console.log(“Current Slug:”, currentSlug);

wixData.query("Blog/Posts")  // FIXED: Use "Blog/Posts"
    .eq("slug", currentSlug)
    .find()
    .then((results) => {
        if (results.items.length > 0) {
            let currentPost = results.items[0];
            console.log("Current Post Found:", currentPost.title);
            
            findNextPost(currentPost);
            findPrevPost(currentPost);
        } else {
            console.log("No matching blog post found.");
        }
    })
    .catch((err) => console.error("Error querying posts:", err));

});

function findNextPost(currentPost) {
wixData.query(“Blog/Posts”) // FIXED
.ascending(“datePublished”)
.gt(“datePublished”, currentPost.datePublished)
.limit(1)
.find()
.then((nextResults) => {
if (nextResults.items.length > 0) {
console.log(“Next Post:”, nextResults.items[0].title);
$w(“#nextButton”).link = /post/${nextResults.items[0].slug};
$w(“#nextButton”).show();
} else {
console.log(“No Next Post Found.”);
}
});
}

function findPrevPost(currentPost) {
wixData.query(“Blog/Posts”) // FIXED
.descending(“datePublished”)
.lt(“datePublished”, currentPost.datePublished)
.limit(1)
.find()
.then((prevResults) => {
if (prevResults.items.length > 0) {
console.log(“Previous Post:”, prevResults.items[0].title);
$w(“#prevButton”).link = /post/${prevResults.items[0].slug};
$w(“#prevButton”).show();
} else {
console.log(“No Previous Post Found.”);
}
});
}