Opened 5 years ago
Last modified 5 years ago
#50084 new defect (bug)
redirect_canonical() need additional hook
Reported by: | Tkama | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | |
Component: | Canonical | Keywords: | |
Focuses: | Cc: |
Description
There is no hook in [redirect_canonical()](https://wp-kama.ru/filecode/wp-includes/canonical.php#L12-625) function that allow as to extend it's logic.
For example, I have the following permastructure /%post_id%/%post_name%
. And I can visit the post by such URL /123
. But I need the redirect to right URL /123/postname
.
And if I try to use the redirect_canonical
hook to fix this BUG, the hook won't work, because it's too late and the hook is never triggers.
At the bottom of the function [we have such code](https://wp-kama.ru/filecode/wp-includes/canonical.php#L572-605):
<?php if ( ! $redirect_url || $redirect_url == $requested_url ) { return; } ... $redirect_url = apply_filters( 'redirect_canonical', $redirect_url, $requested_url );
Why there is no hook before return
? Hook that allows us set our own $redirect_url
...
Change History (3)
Note: See
TracTickets for help on using
tickets.
Hi there, welcome back to WordPress Trac! Thanks for the report.
Just noting this was previously reported in #12456.
If a new hook is intended as a workaround for this particular issue, it seems better to just fix the issue instead.