Opened 13 months ago
Last modified 12 months ago
#59381 new defect (bug)
Issue with WordPress Year Widget for Years Below 1000
Reported by: | idovecer | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | |
Component: | General | Keywords: | has-testing-info has-screenshots has-patch close |
Focuses: | Cc: |
Description
I have noticed that the WordPress year widget does not function correctly when years below 1000 are used. For instance, I have created a history page where historical event dates are entered in WordPress date field. When entering a date with a year below 1000, WordPress displays such dates with leading zeros in admin area.
For example, if I enter the date as 01.01.420 (dd.mm.yyyy), the Year Archive widget leads to /420/, which does not work as expected (4040 Not found). However, if I manually add a leading zero in front /0420/, it displays correctly as /0420/.
How can this issue be resolved?
Thank you.
Change History (9)
This ticket was mentioned in PR #5330 on WordPress/wordpress-develop by @faisal03.
13 months ago
#2
- Keywords has-patch added; needs-patch removed
Trac ticket: https://core.trac.wordpress.org/ticket/59381
This PR adds leading zeros when year has less than 4 digits.
## Steps to Test
- With a block theme active, add an Archive block to a page template.
- Set permalinks to use "Month" based URL structure.
- Create or modify a post and set the post date to a year earlier than 1000, for example 420.
- Save and view/preview the post on the frontend.
- The Archive block's representation of the year should include leading zeros.
- The
/420
archive listing page should work and does not show to a 404.
@faisal03 commented on PR #5330:
13 months ago
#3
This is ready for Code Review.
This ticket was mentioned in Slack in #core by faisal03. View the logs.
13 months ago
#7
@
13 months ago
- Keywords needs-testing removed
Test Report
---
Testing Environment
- WordPress - 6.4-beta1-56736
- Web Server: Nginx
- Chrome Version - 116
- Firefox - 117
- Theme: Twenty Twenty-Three
- PHP - 7.4.0
Test Result
Works as expected With a block theme and an Archive block in the page template, Please check the below video proof.
Video proof
https://imgur.com/zCdlHXY.mp4
Tested PR:
https://github.com/WordPress/wordpress-develop/pull/5330
@ironprogrammer commented on PR #5330:
12 months ago
#8
Thanks for the patch, @faisal-alvi!
I wonder what consensus is on the frontend's _display_ of years < 1000, versus how the slugs are formatted. For instance comparing:
- September 26, 520
- September 26, 0520
I prefer the first, without the leading zero. That's the English standard (e.g. Wikipedia's date guidelines), but I'm unsure for other languages/cultures. Rather than make a suggestion to change this at this time, I feel that additional contributor input would be valuable.
As for slugs, they're currently forced into YYYY
format, so the update to the underlying anchor links in the archive list function how I'd expect.
Welcome to Trac, @idovecer, and thanks for the report!
I am able to reproduce this issue with Twenty Twenty-One in the default Archives sidebar widget (Figure 1).
I'm also able to reproduce in Twenty Twenty-Three (block theme) by adding the Archive block in the site editor (Figure 2). The following report reflects those results.
Reproduction Report
Steps to Reproduce
yyyy
format).Environment
Actual Results
Supplemental Artifacts
Figure 1:
Figure 2: