[wp-trac] [WordPress Trac] #32651: get_adjacent_post() doesn't return posts with the same date

WordPress Trac noreply at wordpress.org
Mon Jun 24 05:28:53 UTC 2019


#32651: get_adjacent_post() doesn't return posts with the same date
---------------------------------------+-----------------------------
 Reporter:  willybahuaud               |       Owner:  (none)
     Type:  defect (bug)               |      Status:  new
 Priority:  normal                     |   Milestone:  Future Release
Component:  Posts, Post Types          |     Version:  4.3
 Severity:  normal                     |  Resolution:
 Keywords:  needs-patch needs-testing  |     Focuses:  template
---------------------------------------+-----------------------------
Changes (by boodaah):

 * keywords:  has-patch => needs-patch needs-testing


Comment:

 This issues still exists in version 5.2.x -- and it was reported on ticket
 #42936 also. The fix above by wonderboymusic needs to be adjusted slightly
 to work with the updates to the core since. Something like this...

 src/wp-includes/link-template.php
 -1821    $sort = apply_filters( "get_{$adjacent}_post_sort", "ORDER BY
 p.post_date $order LIMIT 1", $post, $order );
 +1821    $sort = apply_filters( "get_{$adjacent}_post_sort", "ORDER BY
 p.post_date $order, p.ID $order LIMIT 1", $post, $order );

 With the speed of servers now, it's quite easy to have multiple new posts
 created in the same second, so the sort order needs to have additional
 sort information to create a unique sort and the ID is a logical source
 for a unique sort.

 This might seem like a small change but at least these other functions
 rely on the same line of code: get_adjacent_post, get_previous_post,
 get_next_post, get_adjacent_post_rel_link, adjacent_posts_rel_link,
 next_post_rel_link, prev_post_rel_link, get_previous_post_link,
 get_next_post_link, get_adjacent_post_link, adjacent_post_link

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/32651#comment:8>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list