#10219 closed defect (bug) (fixed)
"Older Entries" and "Newer Entries" links are wrong when entries displayed in ascending order
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 6.9 | Priority: | normal |
| Severity: | normal | Version: | 3.2 |
| Component: | Bundled Theme | Keywords: | has-test-info has-patch commit |
| Focuses: | ui, accessibility, template | Cc: |
Description
I added "?order=ASC" to a tag URL I was sending out to some people, because I wanted them to view a set of blog postings in ascending chronological order, and I noticed that the "Older Entries" and "Newer Entries" links at the bottom of the page were reversed.
I fixed this with the attached changes to the default theme. I don't know if this is the "right" fix, but it worked for me, and if it isn't quite wrong, perhaps at least it will give a more experienced WordPress developer than I an idea for how to fix it properly.
Attachments (4)
Change History (64)
#1
@
17 years ago
- Component changed from General to Template
- Keywords needs-patch added
- Milestone changed from Unassigned to 2.9
- Priority changed from normal to low
- Severity changed from normal to minor
the functions should be fixed, rather.
#3
@
16 years ago
The functions should probably swap behavior when order is swapped.
Closed #10219 as a duplicate.
#4
@
16 years ago
- Milestone changed from 3.0 to Future Release
- Type changed from defect (bug) to enhancement
#6
@
10 years ago
- Keywords needs-testing added
- Priority changed from low to normal
- Severity changed from minor to normal
#7
@
10 years ago
For these reasons I believe this should be closed:
- The issue here isn't a matter of the get_* functions passing invalid urls, it's a matter of a theme's use of the label arg previous_/next_posts_link() and popular disregard for an
orderquery param. - The default labels for these functions' nomenclature is correct since it uses
Next Page »and« Previous Page, instead of the Older/Newer.
However, I'm assuming we want to fix this issue with older core themes (pre-twenty-thirteen), which IMO is a superfluous, I'll work on those patches now.
#8
@
10 years ago
Since @chriscct7 punted this for @nacin to review I'm going to make this easier to understand just in case the circular logic is causing a misunderstanding.
Note: this example is using twenty thirteen...
The "older/newer" terminology isn't correct for obvious reasons, this isn't because the function is using the wrong terminology based on ascending order being used, it's because the labels being passed to the functions are incorrectly set.

This shows that without the labels being sent that the functions return the correct labels.

So, it's not a matter of switching the labels to something dependent on the sort order, it's a matter of the labels these older themes are using.
I can patch these older themes and I'll likely just do it since I'm now invested in this ticket (since my plan was to move on to another here at Contributor Day).
@
10 years ago
Minor mods of previous patch, along with additional support of twenty-twelve and twenty-eleven.
#9
@
10 years ago
- Keywords has-patch added; needs-patch removed
Marking this as having a patch; "needs-testing" can be removed because unit tests can't be written for this type of bug (AFAIK), instead I tested the themes patched. I've attached images of each theme below to show that we don't need to worry about the order of these links/elements (i.e. since "Older posts" link could be after "Newer posts" in the markup) and the CSS floating the elements improperly/non-aligned.
#10
@
7 months ago
- Component changed from Posts, Post Types to Bundled Theme
- Focuses ui accessibility added
- Keywords good-first-bug has-test-info needs-patch added; needs-testing has-patch removed
- Type changed from enhancement to defect (bug)
- Version set to 3.2
Reproduction Report
Description
✅ This report validates that the issue can be reproduced.
Environment
- WordPress: 6.9-alpha-60093-src
- PHP: 8.2.28
- Server: nginx/1.27.5
- Database: mysqli (Server: 8.4.5 / Client: mysqlnd 8.2.28)
- Browser: Chrome 137.0.0.0
- OS: Windows 10/11
- Theme: Twenty Thirteen 4.4
- MU Plugins: None activated
- Plugins:
- Test Reports 1.2.0
Testing Instructions
- Add many posts and assign the same TAG to all, for example tag
test - Go to
/tag/test/?order=ASC - Check the order and the navigation buttons
- 🐞
Older Posts/Newer Postslinks are switched around. Older posts are linking to Newer posts and Newer Posts are linking to Older Posts.
- Important Note: If you switch to
/tag/test/?order=DESCthen links are correct. - The problem here is that
Older Posts/Newer Postsdon't take in consideration theorderparameter.
Actual Results
- ✅ Error condition occurs (reproduced).
Additional Notes
- For the screencast I'm using 2013, but manually I've tested all themes from 2011 to 2025 and this is affecting the following themes:
- 🐞 2011
- 🐞 2012
- 🐞 2013
- 🐞 2019
- 🐞 2020
- 🐞 2021
- 2014, 2015, 2016, 2017, 2022, 2023, 2024, 2025 doesn't use the Older/Newer Posts but a regular pagination, or a next/previous page format, so this issue doesn't affect these themes
- Given that the patches are not applying, and they are so old, I'm adding back
needs-patchto see if it brings some attention. I think that this is interesting because it might also be affecting future themes.
- I believe that this could impact
Accessibilitybecause texts are giving wrong directions.
Supplemental Artifacts
Screencast with the problem:
https://f003.backblazeb2.com/file/wordpress-videos/wp-videos/2025/06/10219.mp4
This ticket was mentioned in PR #9079 on WordPress/wordpress-develop by @shreya0shrivastava.
7 months ago
#11
- Keywords has-patch added; needs-patch removed
Fixes the issue: "Older Entries" and "Newer Entries" links are wrong when entries displayed in ascending order for the Twenty Twenty-One theme by adding dynamic labels according to the order query var (DESC or ASC)
Trac ticket: https://core.trac.wordpress.org/ticket/10219
---
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.
#12
follow-up:
↓ 13
@
7 months ago
I've created a new PR for fixing this issue in the Twenty Twenty-One theme via the twenty_twenty_one_the_posts_navigation() function and made labels dynamic according to the order query var.
Thanks!
#13
in reply to:
↑ 12
;
follow-up:
↓ 14
@
7 months ago
Replying to shreya0shrivastava:
I've created a new PR for fixing this issue in the Twenty Twenty-One theme via the
twenty_twenty_one_the_posts_navigation()function and made labels dynamic according to theorderquery var.
Thanks!
Hello Shreya
Looks mostly good for me
I think you can create a PR per theme of the other 5 I mentioned, following more or less the same philosophy you took here.
#14
in reply to:
↑ 13
;
follow-up:
↓ 22
@
7 months ago
Replying to SirLouen:
Replying to shreya0shrivastava:
I've created a new PR for fixing this issue in the Twenty Twenty-One theme via the
twenty_twenty_one_the_posts_navigation()function and made labels dynamic according to theorderquery var.
Thanks!
Hello Shreya
Looks mostly good for me
I think you can create a PR per theme of the other 5 I mentioned, following more or less the same philosophy you took here.
Thank you for the review!
I'll be creating PRs for the other themes shortly.
#15
@
7 months ago
- Keywords good-first-bug removed
- Milestone set to Awaiting Review
Please avoid creating new translatable strings in these themes, especially in their templates.
Twenty Twenty-One can use the existing strings.
@shreya0shrivastava commented on PR #9079:
7 months ago
#16
@sabernhardt Thank you for the review! I've made the suggested changes.
This ticket was mentioned in PR #9082 on WordPress/wordpress-develop by @shreya0shrivastava.
7 months ago
#17
Similar to #9079
Fixes the issue: "Older Entries" and "Newer Entries" links are wrong when entries displayed in ascending order for the Twenty Twenty theme by adding dynamic labels according to the order query var (DESC or ASC). More info in the trac ticket.
Trac ticket: https://core.trac.wordpress.org/ticket/10219
This ticket was mentioned in PR #9089 on WordPress/wordpress-develop by @shreya0shrivastava.
7 months ago
#18
Similar to PR, PR
Fixes the issue: "Older Entries" and "Newer Entries" links are wrong when entries displayed in ascending order for the Twenty Nineteen theme by adding dynamic labels according to the order query var (DESC or ASC). More info in the trac ticket.
Trac ticket: https://core.trac.wordpress.org/ticket/10219
This ticket was mentioned in PR #9090 on WordPress/wordpress-develop by @shreya0shrivastava.
7 months ago
#19
Similar to PR, PR, PR
Fixes the issue: "Older Entries" and "Newer Entries" links are wrong when entries displayed in ascending order for the Twenty Thirteen theme by adding dynamic labels according to the order query var (DESC or ASC). Also updated the div classes (These classes controlled the position of the labels) for the nav labels to switch according to the order. For context:
---
Trac ticket: https://core.trac.wordpress.org/ticket/10219
This ticket was mentioned in PR #9133 on WordPress/wordpress-develop by @shreya0shrivastava.
7 months ago
#20
Similar to PR
Fixes the issue: "Older Entries" and "Newer Entries" links are wrong when entries displayed in ascending order for the Twenty Twelve theme by adding dynamic labels according to the order query var (DESC or ASC). More info in trac ticket.
---
Trac ticket: https://core.trac.wordpress.org/ticket/10219
This ticket was mentioned in PR #9135 on WordPress/wordpress-develop by @shreya0shrivastava.
7 months ago
#21
Similar to PR, PR
Fixes the issue: "Older Entries" and "Newer Entries" links are wrong when entries displayed in ascending order for the Twenty Eleven theme by adding dynamic labels according to the order query var (DESC or ASC). More info in trac ticket.
---
Trac ticket: https://core.trac.wordpress.org/ticket/10219
#22
in reply to:
↑ 14
;
follow-up:
↓ 23
@
7 months ago
Replying to shreya0shrivastava:
Replying to SirLouen:
Replying to shreya0shrivastava:
I've created a new PR for fixing this issue in the Twenty Twenty-One theme via the
twenty_twenty_one_the_posts_navigation()function and made labels dynamic according to theorderquery var.
Thanks!
Hello Shreya
Looks mostly good for me
I think you can create a PR per theme of the other 5 I mentioned, following more or less the same philosophy you took here.
Thank you for the review!
I'll be creating PRs for the other themes shortly.
I've created the PRs for the other 5 themes as well. Looking forward to the feedback!
cc: @SirLouen @sabernhardt
#23
in reply to:
↑ 22
@
7 months ago
Replying to shreya0shrivastava:
I've created the PRs for the other 5 themes as well. Looking forward to the feedback!
Reviewed, sent some comment.
@sabernhardt commented on PR #9090:
7 months ago
#24
For Twenty Thirteen and older themes, nav-previous still needs to be in the markup before nav-next so the visual order and DOM order match. (See Meaningful Sequence and Focus Order.)
I also do not think Twenty Thirteen should add the 10-pixel margin on the opposite side of the meta-nav arrows.
@shreya0shrivastava commented on PR #9090:
7 months ago
#25
Refactored to remove redundant checks using $is_desc and preserved the .nav-previous / .nav-next DOM order. Please let me know if this looks good, I’ll follow the same pattern in the PRs for the older themes as well. Thanks!
cc: @sabernhardt
#26
@
6 months ago
I've addressed the feedbacks and made some changes for 2013/2012/2011 theme PRs. Please have a look when convenient. Thanks!
cc: @SirLouen @sabernhardt
#27
follow-up:
↓ 28
@
6 months ago
Hi @sabernhardt @SirLouen just checking in to see if any changes are required on these PRs. Thanks!
#28
in reply to:
↑ 27
;
follow-up:
↓ 29
@
6 months ago
Replying to shreya0shrivastava:
Hi @sabernhardt @SirLouen just checking in to see if any changes are required on these PRs. Thanks!
The last time I remember I think it was ready, and I sent you some extra little review that you fixed right? unless you have done any additional changes
#29
in reply to:
↑ 28
@
6 months ago
The last time I remember I think it was ready, and I sent you some extra little review that you fixed right? unless you have done any additional changes
Yes, I have fixed those changes. No additional changes made after that.
#30
follow-up:
↓ 31
@
6 months ago
Replying to shreya0shrivastava:
The last time I remember I think it was ready, and I sent you some extra little review that you fixed right? unless you have done any additional changes
Yes, I have fixed those changes. No additional changes made after that.
@shreya0shrivastava I've sent you this patch for 2011 with the idea to simplify the code a bit and avoid kses that I don't think they are required. The idea was to simplify as much as possible. I think you could apply similar logic for 2012 and 2013. Give it a check and give me your opinion and once you have reach a conclusion, you can send a commit to your PR with the latest changes.
#31
in reply to:
↑ 30
;
follow-up:
↓ 32
@
6 months ago
@shreya0shrivastava I've sent you this patch for 2011 with the idea to simplify the code a bit and avoid
ksesthat I don't think they are required. The idea was to simplify as much as possible. I think you could apply similar logic for 2012 and 2013. Give it a check and give me your opinion and once you have reach a conclusion, you can send a commit to your PR with the latest changes.
Thanks for the review! The changes are very neat and do make the code simpler but I think we need to preserve the DOM order of the markup (nav-previous class element should be before nav-next class element). Would love to know your thoughts on how we can achieve that while also making the code neater.
ref: https://github.com/WordPress/wordpress-develop/pull/9090#issuecomment-3020524140
#32
in reply to:
↑ 31
@
6 months ago
Replying to shreya0shrivastava:
@shreya0shrivastava I've sent you this patch for 2011 with the idea to simplify the code a bit and avoid
ksesthat I don't think they are required. The idea was to simplify as much as possible. I think you could apply similar logic for 2012 and 2013. Give it a check and give me your opinion and once you have reach a conclusion, you can send a commit to your PR with the latest changes.
Thanks for the review! The changes are very neat and do make the code simpler but I think we need to preserve the DOM order of the markup (nav-previous class element should be before nav-next class element). Would love to know your thoughts on how we can achieve that while also making the code neater.
ref: https://github.com/WordPress/wordpress-develop/pull/9090#issuecomment-3020524140
Sure, you can preserve the order as you say. I just sent the patch as a reference for you to review and add.
This ticket was mentioned in Slack in #accessibility by joedolson. View the logs.
6 months ago
#34
@
6 months ago
- Milestone changed from Awaiting Review to 6.9
- Owner set to joedolson
- Status changed from new to accepted
This seems like a good thing to get fixed; thank you all for all your work on this!
@shreya0shrivastava commented on PR #9135:
6 months ago
#35
Hey @SirLouen!
I initially implemented the code you shared since it did help simplify the logic. However, I later realized that while the output visually looked correct, it did not preserve the DOM order of .nav-previous followed by .nav-next in all cases.
Ref:
<?php if ( get_query_var( 'order', 'DESC' ) === 'DESC' ) : ?> <div class="nav-previous"><?php next_posts_link( $left_arrow . $old_posts_text ); ?></div> <div class="nav-next"><?php previous_posts_link( $new_posts_text . $right_arrow ); ?></div> <?php else : ?> <div class="nav-next"><?php previous_posts_link( $old_posts_text . $right_arrow ); ?></div> <div class="nav-previous"><?php next_posts_link( $left_arrow . $new_posts_text ); ?></div> <?php endif; ?>
This affects the meaningful sequence and focus order requirements as described in the WCAG 2.2 guidelines on Meaningful Sequence and Focus Order, which are important for accessibility. So I had to revert that commit. I am currently looking for ways to keep the code simple while ensuring the DOM order remains consistent and accessible. Let me know if you have any thoughts on how we can achieve both.
Thanks again for the review!
@SirLouen commented on PR #9135:
6 months ago
#36
This affects the meaningful sequence and focus order requirements as described in the WCAG 2.2 guidelines on Meaningful Sequence and Focus Order, which are important for accessibility. So I had to revert that commit. I am currently looking for ways to keep the code simple while ensuring the DOM order remains consistent and accessible. Let me know if you have any thoughts on how we can achieve both.
Ping me out if you figure out something without making the code too repetitive.
This ticket was mentioned in Slack in #accessibility by joedolson. View the logs.
3 months ago
This ticket was mentioned in Slack in #accessibility by zobaerus. View the logs.
3 months ago
@shailu25 commented on PR #9089:
3 months ago
#39
@shailu25 commented on PR #9133:
3 months ago
#40
@shailu25 commented on PR #9135:
3 months ago
#41
@shailu25 commented on PR #9090:
3 months ago
#42
@shailu25 commented on PR #9082:
3 months ago
#43
@shailu25 commented on PR #9079:
3 months ago
#44
This ticket was mentioned in PR #10359 on WordPress/wordpress-develop by @sabernhardt.
3 months ago
#45
Updates link references for both navigation sections of Twenty Ten's loop.php.
#46
@
3 months ago
I tested five URLs:
These three all displayed posts in the default descending order.
http://localhost/svn/src/tag/alice/page/2/ http://localhost/svn/src/tag/alice/page/2/?order=DESC http://localhost/svn/src/tag/alice/page/2/?order=desc
Both of these displayed posts in ascending order, regardless of letter case.
http://localhost/svn/src/tag/alice/page/2/?order=ASC http://localhost/svn/src/tag/alice/page/2/?order=asc
Twenty Ten has the posts navigation links in a loop.php template instead of functions.php, and I just made that PR in a manner similar to the patches for T11, T12 and T13.
@shailu25 commented on PR #10359:
3 months ago
#47
This ticket was mentioned in Slack in #accessibility by joedolson. View the logs.
3 months ago
#50
@
3 months ago
- Keywords commit added; reviewing removed
Twenty Twenty One: PR refreshed and verified. Ready for commit.
Twenty Twenty: PR refreshed and verified. Ready for commit.
Twenty Nineteen: PR refreshed and verified. Ready for commit.
Twenty Thirteen: PR refreshed and verified. Ready for commit.
Twenty Twelve: PR refreshed and verified. Ready for commit.
Twenty Eleven: PR refreshed and verified. Ready for commit.
Twenty Ten: pending.
I removed wp_kses_post from the PRs that added it. This seems like an unnecessary extra step with a relatively expensive function. There's no difference in escaping between the two function variants in these patches.
@sabernhardt I can see that you're actively working on the Twenty Ten PR right now, so I'm leaving that as pending, but marking this ticket for commit. Update this when you're ready.
#51
@
3 months ago
I'm done editing the PR for Twenty Ten. Now it does not have wp_kses_post() in either section, and it sets the $is_desc variable in one line (without setting an $order variable).
I also checked each PR with the pre_get_posts filter and no query string in the URL:
http://localhost/svn/src/tag/alice/page/2/
function sort_posts_by_date_ascending( $query ) {
if ( $query->is_main_query() && ! is_admin() && $query->is_tag() ) {
$query->set( 'orderby', 'date' );
$query->set( 'order', 'ASC' );
}
}
add_action( 'pre_get_posts', 'sort_posts_by_date_ascending' );
That sets the posts in ascending order, and the labels match the correct direction.
Twenty Twenty example:
<nav class="navigation pagination" aria-label="Posts pagination"> <h2 class="screen-reader-text">Posts pagination</h2> <div class="nav-links"><a class="prev page-numbers" href="http://localhost/svn/src/tag/alice/"><span aria-hidden="true">←</span> <span class="nav-prev-text">Older <span class="nav-short">Posts</span></span></a> <a class="page-numbers" href="http://localhost/svn/src/tag/alice/">1</a> <span aria-current="page" class="page-numbers current">2</span> <a class="page-numbers" href="http://localhost/svn/src/tag/alice/page/3/">3</a> <a class="page-numbers" href="http://localhost/svn/src/tag/alice/page/4/">4</a> <a class="next page-numbers" href="http://localhost/svn/src/tag/alice/page/3/"><span class="nav-next-text">Newer <span class="nav-short">Posts</span></span> <span aria-hidden="true">→</span></a></div> </nav>
(And it honors the filter's ASC sorting even if the URL has a ?order=DESC query string.)
This ticket was mentioned in Slack in #core by joedolson. View the logs.
2 months ago
@sabernhardt commented on PR #10359:
2 months ago
#60
Committed in r61097



patch to to switch the links when displaying in ascending order