Opened 4 years ago
Last modified 3 years ago
#52737 new enhancement
Allow 301 redirect on _wp_old_slug to be filterable
Reported by: | brookedot | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | |
Component: | Permalinks | Keywords: | has-patch needs-testing |
Focuses: | Cc: |
Description
While the URL on old_slug_redirect_url
is filterable the same should be true for the redirect status. It currently is hardcoded as a 301. Allowing any status code will allow for 302 or other status to be used.
https://core.trac.wordpress.org/browser/trunk/src/wp-includes/query.php#L1082
Attachments (3)
Change History (6)
#2
@
4 years ago
- Keywords needs-refresh removed
As per wp_redirect document $status use int parameter.
Good catch, updated in 52737.3.2.patch
. Not sure why my patch naming was off, but the patch itself should be good.
I'll also mention #40032 as a tangentially related ticket that also touches this code. If both are implemented the one that is added second may need an additional be refresh,
#3
@
3 years ago
Thanks for the patch, this makes sense:
- Minor nit pick: the
permanent redirect
comment next to wp_redirect can be deleted as it may not be permanent. - I think it would be handy to include the post ID or post object as a second parameter on the new filter, this will allow developers to use different status codes under different circumstances.
(BTW: Trac's patch renaming can be weird, if you upload files with 52737.patch
or 52737.diff
trac will do a better job working out if it needs to rename.)
As per wp_redirect document
$status
use int parameter. So we have to change the doc block for the filter like below