[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
Fri Mar 7 18:07:55 UTC 2014
#8107: get_next_post, get_previous_post do not work for posts posted within same
second
----------------------------------------+-----------------------------
Reporter: whoismanu | Owner:
Type: defect (bug) | Status: new
Priority: low | Milestone: Future Release
Component: Posts, Post Types | Version: 2.7
Severity: minor | Resolution:
Keywords: needs-testing dev-feedback | Focuses: template
----------------------------------------+-----------------------------
Changes (by billerickson):
* keywords: has-patch needs-testing => needs-testing dev-feedback
Comment:
In versions 3.8 and less, when using previous/next post links any posts
with the same published date and time as the current post are skipped.
In version 3.9, you get stuck in a loop, going back and forth between
posts in the same date. This is because the date_query has 'inclusive' =>
true and we're excluding the current post date.
I played around with it a bit and couldn't come up with a single WP Query
that queried either posts ordered by date with different published dates
OR posts ordered by ID with the same published date. Doing 'orderby' =>
'date ID' didn't do it.
I think we might need to do multiple queries. Keep the current one, but
before we return the adjacent post, check to see if the date matches the
current post. If it does, query for posts with that same date, sorted by
post ID (to end the loop we're in). If no results for that, do the
original adjacent post query but set 'inclusive' => false.
I'm happy to write the patch, but that's a lot of queries. Is there a more
efficient approach?
--
Ticket URL: <https://core.trac.wordpress.org/ticket/8107#comment:14>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list