Make WordPress Core

Opened 16 years ago

Last modified 10 days ago

#10219 new defect (bug)

"Older Entries" and "Newer Entries" links are wrong when entries displayed in ascending order

Reported by: jikamens's profile jikamens Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 3.2
Component: Bundled Theme Keywords: has-test-info has-patch
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 (3)

ASC-links.patch (3.8 KB) - added by jikamens 16 years ago.
patch to to switch the links when displaying in ascending order
10219.diff (2.3 KB) - added by obenland 10 years ago.
It's not pretty.
10219-2.diff (5.7 KB) - added by dancameron 10 years ago.
Minor mods of previous patch, along with additional support of twenty-twelve and twenty-eleven.

Download all attachments as: .zip

Change History (29)

@jikamens
16 years ago

patch to to switch the links when displaying in ascending order

#1 @Denis-de-Bernardy
16 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.

#2 @nacin
16 years ago

  • Milestone changed from 2.9 to 3.0

#3 @nacin
15 years ago

The functions should probably swap behavior when order is swapped.

Closed #10219 as a duplicate.

#4 @nacin
15 years ago

  • Milestone changed from 3.0 to Future Release
  • Type changed from defect (bug) to enhancement

#5 @nacin
11 years ago

  • Component changed from Template to Posts, Post Types
  • Focuses template added

#6 @chriscct7
10 years ago

  • Keywords needs-testing added
  • Priority changed from low to normal
  • Severity changed from minor to normal

#7 @dancameron
10 years ago

For these reasons I believe this should be closed:

  1. 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 order query param.
  2. 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 @dancameron
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.
https://s3.amazonaws.com/f.cl.ly/items/1V3d1R1D2d010e2d0032/Screen%20Shot%202015-12-06%20at%2012.37.00%20PM.png

This shows that without the labels being sent that the functions return the correct labels.
https://s3.amazonaws.com/f.cl.ly/items/2E370x0H351c3e222t2P/Screen%20Shot%202015-12-06%20at%2012.36.36%20PM.png

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).

@obenland
10 years ago

It's not pretty.

@dancameron
10 years ago

Minor mods of previous patch, along with additional support of twenty-twelve and twenty-eleven.

#9 @dancameron
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.

https://s3.amazonaws.com/f.cl.ly/items/452I141d2y413k0i0T1g/Screen%20Shot%202015-12-06%20at%203.13.07%20PM.png

https://s3.amazonaws.com/f.cl.ly/items/1G3n223G1j0U2S2i341e/Screen%20Shot%202015-12-06%20at%203.13.57%20PM.png

https://s3.amazonaws.com/f.cl.ly/items/2x272G0c360k2g2c1k34/Screen%20Shot%202015-12-06%20at%203.24.08%20PM.png

#10 @SirLouen
4 weeks 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

  1. Add many posts and assign the same TAG to all, for example tag test
  2. Go to /tag/test/?order=ASC
  3. Check the order and the navigation buttons
  4. 🐞 Older Posts/Newer Posts links 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=DESC then links are correct.
  • The problem here is that Older Posts/Newer Posts don't take in consideration the order parameter.

Actual Results

  1. ✅ 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:
  1. 🐞 2011
  2. 🐞 2012
  3. 🐞 2013
  4. 🐞 2019
  5. 🐞 2020
  6. 🐞 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-patch to 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 Accessibility because 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.


3 weeks 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: @shreya0shrivastava
3 weeks 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: @SirLouen
3 weeks 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 the order query 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: @shreya0shrivastava
3 weeks 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 the order query 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 @sabernhardt
3 weeks 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:


3 weeks 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.


3 weeks 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.


3 weeks 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.


3 weeks 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:

### Without switching classes
https://github.com/user-attachments/assets/19e09591-244f-4a4f-8f03-8a22d2623bda

### Switching classes
https://github.com/user-attachments/assets/bfa48a45-ff17-4389-b174-5b0905678c30

---

Trac ticket: https://core.trac.wordpress.org/ticket/10219

This ticket was mentioned in PR #9133 on WordPress/wordpress-develop by @shreya0shrivastava.


2 weeks 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.


2 weeks 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: @shreya0shrivastava
2 weeks 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 the order query 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 @SirLouen
2 weeks 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:


2 weeks 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:


2 weeks 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 @shreya0shrivastava
10 days 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

Note: See TracTickets for help on using tickets.