Opened 3 years ago
Closed 2 years ago
#15487 closed defect (bug) (fixed)
Custom permalinks redirecting back to category list instead of post
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Priority: | high | Milestone: | 3.1 |
| Component: | Canonical | Version: | 3.1 |
| Severity: | blocker | Keywords: | |
| Cc: | tar.gz |
Description
Using a custom permalink structure such as
/%category%/%post_id%/%postname%/
hitting a post permalink will redirect you back to the category although debugging via a filter attached to parse_request shows the correct query (matched_query).
Attachments (3)
Change History (29)
- Component changed from Rewrite Rules to Canonical
- Keywords needs-patch added; permalink_structure wp_rewrite rewrite removed
- Milestone changed from Awaiting Review to 3.1
canonical.php is confused. I think it sees this as a tax query rather than a single post query.
It is broken for all instances of %category% in your permalinks e.g. /archives/%category%/%postname% is broken as well
comment:6
markjaquith — 3 years ago
is_category is being set, and it shouldn't be.
comment:7
markjaquith — 3 years ago
- Resolution set to fixed
- Status changed from new to closed
- Resolution fixed deleted
- Status changed from closed to reopened
Still broken, and is sort of worse now. Can end up in infinite redirect loops, or lead to pages instead of posts. Must be more to this, unless I have borked my testbed install somehow.
From what I can tell, if there is only one post in the category WordPress is able to find the correct page 100% of the time. If there are multiple posts in the category, it seems like the most recent post is the only one that will load reliably. This is true for all categories except the default category (Uncategorized or as I have it renamed General). The default category is broken, all of the posts that are members of it end up getting stuck in redirect loops.
comment:9
markjaquith — 3 years ago
- Priority changed from normal to high
- Severity changed from normal to blocker
My fault... had some code in mu-plugins that was messing with redirects. I see the problem exhibited fully, now. Bumping up priority/severity. Can take a look tonight, but if someone wants to take a swing in the meantime, go ahead.
is_category should be FALSE for these requests, because they're is_single requests. And the category portion of the URL is typically ignored when making the query (because you have a unique post slug or ID) — that may have changed in 3.1
comment:10
scribu — 3 years ago
I'm looking into this now.
comment:11
ryan — 3 years ago
comment:12
automattor — 3 years ago
comment:13
mtekk — 3 years ago
Looks like the last commit by automattor fixed it. Anyone else confirm?
comment:14
ryan — 2 years ago
- Resolution set to fixed
- Status changed from reopened to closed
comment:15
tar.gz — 2 years ago
- Cc tar.gz added
- Resolution fixed deleted
- Status changed from closed to reopened
I'm currently running 3.1-beta1-16732 and I see this issue reappearing on a site that was fine in WP 3.0.3.
My custom link structure is: /%year%/%category%/%postname%/ (since starting with %category% is not recommended for performance reasons).
comment:16
tar.gz — 2 years ago
Note: the previous beta build i was running was [16723], here the permalinks were still working.
Note2: a custom structure such as /%year%/%postname%/ works fine, so it's really the %category% that causes the trouble.
comment:17
garyc40 — 2 years ago
- Owner set to garyc40
- Status changed from reopened to assigned
comment:18
greuben — 2 years ago
- Keywords has-patch added; needs-patch removed
comment:19
greuben — 2 years ago
- Keywords needs-patch added; has-patch removed
The last patch works but is not returning proper results
comment:20
greuben — 2 years ago
- Keywords needs-testing added; needs-patch removed
comment:21
greuben — 2 years ago
- Keywords needs-patch added; needs-testing removed
whoops...working at wrong file and lines
comment:22
mtekk — 2 years ago
Looks like scribu broke it in [16851]
comment:23
scribu — 2 years ago
comment:24
scribu — 2 years ago
Should be fixed now. Please confirm.
comment:25
scribu — 2 years ago
- Keywords needs-patch removed
comment:26
mtekk — 2 years ago
- Resolution set to fixed
- Status changed from assigned to closed
Ok, works for me now, again, closing as fixed

[15825]