[wp-trac] [WordPress Trac] #8107: get_next_post, get_previous_post do not work for posts posted within same second
WordPress Trac
noreply at wordpress.org
Sun Oct 26 21:19:23 UTC 2025
#8107: get_next_post, get_previous_post do not work for posts posted within same
second
-------------------------------------------------+-------------------------
Reporter: whoismanu | Owner: ramonopoly
Type: defect (bug) | Status: closed
Priority: normal | Milestone: 6.9
Component: Posts, Post Types | Version: 2.7
Severity: normal | Resolution: fixed
Keywords: has-test-info has-patch has-unit- | Focuses: template
tests |
-------------------------------------------------+-------------------------
Changes (by ramonopoly):
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"61066" 61066]:
{{{
#!CommitTicketReference repository="" revision="61066"
get_adjacent_post: modify WHERE clause to include ID-based fallback to
ensure deterministic ordering
Since WordPress 2.7, where multiple posts have identical post_date values
(e.g., when bulk publishing drafts), the next/previous post navigation
skips posts or behaves unpredictably. This is because the WHERE clause
uses strict inequality (`>` or `<`) which excludes posts with the same
date.
To ensure deterministic ordering, this commit modifies the WHERE clause to
include ID-based fallback for posts with identical dates.
Props ramonopoly, westonruter, andrewserong.
Fixes #8107.
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/8107#comment:28>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list