Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

@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.

-Mike

share|improve this answer
    
The Creating 301 Redirects for Post, Page... uses template_redirect which seems to come after content has been queried. I verified this with your instrument-hooks plugin. This seems to me to be too late in the process as doing a query would wasted since I know no content will exist there. Love the instrument-hooks plugin, btw! –  Beau Simensen Sep 8 '10 at 18:49
    
@Beau Simensen: That's why I suggested plugsin_loaded at the top of my answer. I was suggesting it with the code in the "Creating 301..." answer. –  MikeSchinkel Sep 8 '10 at 20:48

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.