[wp-trac] [WordPress Trac] #52220: Weekly archives/week 53 incorrect crossing over a year change

WordPress Trac noreply at wordpress.org
Tue Jan 5 14:46:00 UTC 2021


#52220: Weekly archives/week 53 incorrect crossing over a year change
--------------------------+------------------------------
 Reporter:  sugeneris     |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Date/Time     |     Version:  5.6
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:
--------------------------+------------------------------

Comment (by Rarst):

 Examples you are providing are ISO week numbers. In a nutshell WP seems to
 neither support ISO weeks or querying by week and year.

 Here is what happening with the year=2020,w=53.

 You could easily think this queries posts that are ''in week 53 of year
 2020''. **It does not.**

 This queries posts that are ''in year 2020 **AND** week 53''.

 2021-01-01 **is not in year 2020** so it is not selected by this query.

 Also for weeks starting on Monday WP uses MySQL week ''mode 1'' which puts
 2021-01-01 into week 2021-0 (instead of ''mode 3'' ISO week 2020-53) and
 WP doesn't seem to be able to query week 0 at all.

 So my current understanding is:
 1. If you try this query combination there are indeed some "lost" days at
 the end of the year
 2. However WP_Query is ''literally'' correct giving you combination
 requested
 3. There seems to be ''no way'' to query ''week of a specific year''
 4. There seems to be ''no way'' to query ''week 0''
 5. There seems to be ''no way'' to query by ''ISO week'' number

 So as of right now, it seems you would need to figure out custom SQL for
 it, WP_Query just doesn't know how to do this.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/52220#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list