Repository navigation
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
Trac ticket: https://core.trac.wordpress.org/ticket/28081
Description
Any number appended as
/page/{n}/(or?paged={n}) to a page URL currently returns a 200 with the same content as the page itself, e.g./sample-page/page/2323/. Posts don't have this problem:redirect_canonical()strips thepagedpart for them and redirects to the permalink.The cause is the check in the paging block of
redirect_canonical(): it uses! is_single(), which is false for posts, attachments and custom post types but true for pages. So for pages thepagination_base/{n}segment is added back to the redirect URL instead of being dropped.This PR changes that check to
! is_singular(), so pages behave the same as other singular content.What is (and isn't) affected
is_single()andis_singular()are already equivalent.WP_Queryalready converts itspagedintopage(/page/2/for<!--nextpage-->content keeps working, see existingpageOnFronttests).page_for_posts) is unaffected, since it isis_home(), not singular./sample-page/comment-page-2/?paged=2→/sample-page/comment-page-2/.Tests
New tests in
tests/phpunit/tests/canonical/paged.php:/page/2/,/page/2323/,/page/1/on a page → page permalink?paged=2on a page → page permalink/page/3/→ child page permalinkpagedis stripped/blog/page/2/is not redirected (regression)6 of the new tests fail without the fix.
canonical,rewriteandquerygroups pass with it.Use of AI Tools
AI assistance: Yes
Tool(s): Claude
Model(s): Opus 5.5
Used for: Analysis the existing patches, write the tests and draft this description. All changes were reviewed and tested locally by me.
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.