The action ‘loop_start’ fires before each post is output, but a redirect at this point will fail because page content has already been sent.
The filter ‘the_posts’ fires almost immediately after the query returns, but you’d have to sift through all the posts looking for a value. There’s a better chance of a redirect working here though, it depends on the template really, some send content before a query is even run, so a redirect will never work.
Thread Starter
Adam
(@umbercode)
I’ll try both of them, thanks didn’t know about the ‘loop_starts’ one. What about ‘wp’? As I understand it it will also fire before output, but I suspect it will not take custom WP_Queries into account?
Right, ‘wp’ action is much too early, there is no sign of any query being formed at that point. The only thing useful for you there is it’s also before any page output, so a redirect would surely work, except there is no condition to check for, so the redirect would happen every time 🙁
Thread Starter
Adam
(@umbercode)
Ok, thanks again. However I am abandoning this line of thought since it will become near impossible to cater for every possible post/page query like this. So I am going to check the meta-key on the filters ‘the_content’ and ‘the_excerpt’ instead and use a javascript redirect or a content-change. I just hope it will not slow down the site too much.