[wp-trac] [WordPress Trac] #52586: canonical_redirect drops query

WordPress Trac noreply at wordpress.org
Sun Feb 21 23:46:41 UTC 2021


#52586: canonical_redirect drops query
--------------------------+----------------------
 Reporter:  tdlewis77     |       Owner:  (none)
     Type:  defect (bug)  |      Status:  closed
 Priority:  normal        |   Milestone:
Component:  Canonical     |     Version:
 Severity:  normal        |  Resolution:  wontfix
 Keywords:                |     Focuses:
--------------------------+----------------------
Changes (by peterwilsoncc):

 * status:  new => closed
 * resolution:   => wontfix
 * version:  5.6.1 =>
 * component:  General => Canonical
 * milestone:  Awaiting Review =>


Comment:

 Hello and thank you for the report.

 This occurs because page is a [https://codex.wordpress.org/Reserved_Terms
 reserved term] in WordPress. WordPress Core uses the `page=X` query string
 parameter for pagination of posts, pages and custom post types (`page=2`
 is page 2, which redirects to `/my-page/2`).

 In your case, `redirect_canonical()` is working as intended: the function
 is checking for the reserved term to determine if it ought to redirect.
 When the page number doesn't exist it redirects to the first page.

 For the purpose of your code, you will need to change the `page` query
 string parameter to use a term that is not reserved, eg `myplugin_page`.

 As `page` is a reserved term used for WordPress Core, I'm going to close
 this ticket as `wontfix`. It's not the most friendly term, sorry, but in
 this case it's because WordPress can't easily figure out if a reserved
 term should be preserved for a plugin.

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


More information about the wp-trac mailing list