get_next_post() and get_previous_post() return wrong posts

The problem was that WordPress uses these functions based on post_date

I did an import from an old CMS to WordPress where I just added all posts within a loop. Some of the dates were a few seconds off. This caused the functions to return ‘false’ posts.

I actually wrote a custom class that handles getNext() and getPrevious() with a combined function called getSiblings() based on post_id.

I actually wrote a class that fully tackles this problem. Check github for the full code. Contribution would be very much appreciated 🙂