Opened 11 years ago
Last modified 6 years ago
#28026 new defect (bug)
previous_post_link returns incorrect post when posts have the same published date
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.8.3 |
Component: | Themes | Keywords: | has-patch needs-refresh |
Focuses: | template | Cc: |
Description
Version: 3.8.3
Overview: previous_post_link does not return the correct link when posts have exactly the same published date. Instead it, skips the post with the same published date and returns the next found post.
Steps to reproduce:
1) Publish a post. Post A
2) Using wp-admin create 2 draft posts. Draft B, Draft C
3) Switch to the post list view /wp-admin/edit.php
4) Switch to the link showing draft posts /wp-admin/edit.php?post_status=draft&post_type=post
5) Click the checkbox to select all draft posts, then in the Dropdown select Edit then Apply.
6) Change status dropdown to "Published" and then Update.
7) In single.php add a <?php previous_post_link() ?>
8) View Draft C, link should point to Draft B, instead it points to Post A.
Fix:
Quick look indicates that in link-template.php 1179 should be <= and >=
Attachments (4)
Change History (11)
#2
@
11 years ago
- Keywords has-patch added
Yeah, realise this has some complex cases, but as it was possible to cause the bug with the WordPress Admin figured it was worth reporting.
IDs make sense to me, I guess it's the only order we have which is unique?
#3
@
11 years ago
- Focuses template added; ui administration performance removed
- Milestone changed from Awaiting Review to 4.0
Problem is, if you accept retrieving same date posts, they will show up for both
get_previous_post()
andget_next_post()
calls. So when you are on Draft C, you will see Draft B for both previous and next posts...We could fix it by choosing whether Draft B is before or after Draft C, maybe thanks to their IDs?
I'll attach a patch with a reviewed 'WHERE' clause for
get_adjacent_post()
function.