I am trying to figure out which hooks I can tie into in order to read the incoming URL prior to the query actually being run. A quick look tells me maybe wp_loaded
or posts_selection
would be good choices but would hate to miss out on something obviously better for my needs.
template_redirect
sounded promising but seems to be called after content is selected so I do not think that is going to work.
I thought the rewrite code might help, but the likes of generate_rewrite_rules
do not seem to allow for arbitrary code to be executed… it seems to all be geared toward redirecting to existing content.
My goal is to write redirection code that I need to not be tied to an existing piece of content. I have found several plugins that do similar things, but all seem to require that a post or page be added to the system for the redirect to be attached to.
For instance, I want /foo/bar
to redirect to /baz
, but I don’t want to have to create a page foo
or a sub-page of foo
called bar
.
@Hi Beau Simensen:
The hook
plugsin_loaded
is one option, but you can use the plugin I posted for this question to see what plugins are run and in which order and use it to find the hook that works best for you:Given your goal, you might also find this answer useful:
If that wasn’t what you needed please elaborate and I can hopefully offer more.