[wp-trac] [WordPress Trac] #42936: get_adjacent_post won't find any posts that are published in the same minute
WordPress Trac
noreply at wordpress.org
Wed Sep 3 15:28:07 UTC 2025
#42936: get_adjacent_post won't find any posts that are published in the same
minute
--------------------------------------------+-----------------------------
Reporter: sheepysheep60 | Owner: johnbillion
Type: defect (bug) | Status: assigned
Priority: normal | Milestone: Future Release
Component: Posts, Post Types | Version: 4.9.1
Severity: normal | Resolution:
Keywords: good-first-bug has-patch close | Focuses:
--------------------------------------------+-----------------------------
Comment (by kitchin):
Duplicate of #32651 ("get_adjacent_post() doesn't return posts with the
same date")
Duplicate of #49294 ("If multiple posts has same date, get_previous_post()
and get_next_post() returns only first/last of them")
#47642 ("Order by comment count - posts list tables") is irrelevant to
this bug as far as I can tell. It addresses a backend problem due to a
uniqueness problem in WP_Query.
This bug is about the frontend results of `get_adjacent_post()`, which
directly runs a $wpdb query instead of using WP_Query.
The fix is to replace "date `<` $post->date" with "date `<=` $post->date
AND ID != post->ID", and add a clause to the ORDER BY.
That fix is coded in #32651. It is
[https://core.trac.wordpress.org/attachment/ticket/32651/32651.diff
32651.diff], plus ticket:32651#comment8.
Relevant: #26937 ("get_adjacent_post() should use WP_Query rather than
build its own SQL query")
Dupped by: #33076 "(rewrite get_adjacent_post in terms by using wp_query
instead of hand written queries"
Irrelevant: #44349 ("Posts show up multiple times in backend when they
have the exact same date ")
Irrelevant: #53201 ("Admin UI Posts: Pagination via offset uses
inconsistent sorting for tie-breaks")
--
Ticket URL: <https://core.trac.wordpress.org/ticket/42936#comment:22>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list