[wp-trac] [WordPress Trac] #49220: rel_canonical generates the wrong canonical structure for paginated pages.
WordPress Trac
noreply at wordpress.org
Fri Jan 24 17:01:17 UTC 2020
#49220: rel_canonical generates the wrong canonical structure for paginated pages.
--------------------------+------------------------------
Reporter: bradleyt | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Canonical | Version: 4.6
Severity: normal | Resolution:
Keywords: close | Focuses:
--------------------------+------------------------------
Comment (by bradleyt):
Hi @SergeyBiryukov,
Sorry for the delaying in following up on your reply - I have been trying
to check that my thinking is correct in regards to this issue. Firstly,
let me say that this bug can be reproduced on a fresh install of
WordPress. That said, there are a few conditions for this bug to be
reproducible, which I didn't initially realise:
- The `page_on_front` setting needs to be set to a static page. I.e. this
issue does not seem to affect sites where the homepage is an archive.
- Pretty permalinks must be enabled
- The bug is only reproducible on the site homepage.
To give some examples of what that means in practice:
- wordpress.org/page/2/ has the wrong canonical because it is the
homepage for wordpress.org
- wordpress.org/showcase/page/2/ has the wrong canonical because the
showcase pages are actually setup as a standalone WordPress site (as part
of a multisite installation)
- wordpress.org/showcase/submit-a-wordpress-site/page/2/ is not affected,
because it is not the homepage.
- wordpress.org/news/ is not affected because although it is the homepage
of a news site (like the showcase setup) the homepage is not set to show a
static page.
*Note that I am using the term `homepage` to refer to the page served at a
site's root URL, regardless of the setup of that site.
`wp_get_canonical_url` calls `get_query_var( 'page', 0 )`. Normally when
visiting a URL of the style wordpress.local/another-page/page/2/ this
returns 0. However, on an incorrectly paginated homepage such as
wordpress.local/page/2/ this returns the page number - note that calling
`get_query_var( 'paged', 0 )` would also (correctly) return the same page
number.
It seems that the incorrect `page` query variable is originating from
`WP_Query->parse_query` specifically from an area commented as "Correct
is_* for page_on_front and page_for_posts".
I have not got as far as being able to suggest a solution, but for now I
hope that we can move away from the idea that this is related to the
wordpress.org setup and focus on finding a solution. I personally believe
that there are significant backwards-compatibility blockers to #28081
being resolved any time soon, and so I am in favour of this
`wp_get_canonical_url` bug being treated as a standalone issue.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/49220#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list