Ticket #6516 (closed enhancement: fixed)
canonical redirect doesn't redirect ?name=slug
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Priority: | normal | Milestone: | 2.9 |
| Component: | Canonical | Version: | 2.5 |
| Severity: | major | Keywords: | needs-patch |
| Cc: |
Description
domain.com?name=test doesn't seem to be redirecting to domain.com/2008/03/31/test/
Attachments
Change History
I believe that'd be the expected result, at least with the 2.5 branch.
If you were to try domain.com/test it would indeed redirect as expected.
AFAIK, It ignores query vars which it doesnt know about. If you were to access domain.com?p=<post id> then it'd also redirect.
mm, aren't name and pagename (and several others) built-in query vars for WP? If WP cannot reliably redirect things other than ?p=ID, it's really not worth calling this a canonical permalink feature (or whatever it's called). I'd hate to have to reinstall permalink redirect... :-|
- Summary changed from canonical redirect broken to canonical redirect doesn't redirect ?name=slug
- Type changed from defect to enhancement
- Milestone changed from 2.5.1 to 2.7
- Keywords has-patch needs-testing added
- Owner changed from anonymous to markjaquith
- Component changed from Optimization to Canonical
- Milestone changed from 2.9 to 2.8
attachment 6516.diff added.
- Redirects ?name and ?pagename to their permalinks
- WP_Query changes:
- supports querying based on 'pagename' for pages which are not a static front page
- if ( !empty($reqpage) ) was added to prevent querying for page_id == 0, which happens when pagename is a slug & a the page is a subpage (in that case, get_page_by_path() will fail)
- if ('' != $q['name']) block was moved after page/attachment code to reduce duplicate code
Hmm.. Those changes to WP_Query may've been in the wrong thinking, Page slugs are not unique (as is with attachments/posts)
true, but isn't redirecting to something plausible better than outputting a 404?
is_single() and is_page() mean we requested a single object. Can we not use get_queried_object_id() and pass that to get_permalink()?
Imo, we should close this one, and open a grand ticket: Enforce permalink history across the board.
comment:11
follow-up:
↓ 12
DD32 — 3 years ago
Can we not use get_queried_object_id() and pass that to get_permalink()?
Yes, Yes we can. (Except that i'm not aware of the usage of function such as those :))
comment:12
in reply to:
↑ 11
Denis-de-Bernardy — 3 years ago
Replying to DD32:
Can we not use get_queried_object_id() and pass that to get_permalink()?
Yes, Yes we can. (Except that i'm not aware of the usage of function such as those :))
Like this:
get_permalink($wp_query->get_queried_object_id());
- Keywords needs-patch added; has-patch needs-testing removed
- Milestone changed from 2.8 to Future Release
Bumping to Future


same goes for pagename, and presumable others