[wp-hackers] weird permalink issue

Otto otto at ottodestruct.com
Wed Mar 30 16:06:19 UTC 2011


On Wed, Mar 30, 2011 at 8:12 AM, Steve Taylor <steve at sltaylor.co.uk> wrote:
> The system I've built
> intercepts that 404 and serves up a dynamic template.

How does it do that?

If you're hooking into the 404.php template or something, then you're
basically doing it last, which is the wrong way to do it. The
redirect_canonical function which is hooked into template_redirect
will run first, probably going around your 404 logic and serving up
the redirect before your code runs.

Instead, hook your URL detection code into template_redirect with a
higher priority, so as to run before any of the other template stuff
takes effect. Then you can do your output and exit; before any of the
normal template stuff runs.

-Otto


More information about the wp-hackers mailing list