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'm looking for some inspiration on the best way to run a php script away from the template. I know that the wordpress core files won't have loaded, so I am wondering what workgflow you follow when doing this?

cheers

share|improve this question
    
What do you mean by away from the template? –  t31os Feb 8 '11 at 15:30
    
I mean running a script that is inapproprate to run on the current template file. i.e, I need to sent get variables that can't be loaded on to the current page. –  Mild Fuzz Feb 8 '11 at 15:33
add comment

1 Answer

Hi @Mild Fuzz:

Sounds like what you might be looking for is the template_redirect hook. If you add a function for that hook then you can output whatever you want and end with an exit; statement.

add_action( 'template_redirect', 'yoursite_template_redirect' );
function yoursite_template_redirect() {
  if (isset($_GET['foo']) && $_GET['foo']=='bar') {
    // Do whatever you want when $_GET['foo']=='bar'
  }
}

You'll need to figure out what criteria to test for such as I showed with $_GET['foo']=='bar', but is that what you are looking for?

share|improve this answer
    
not 100% on when this will action, could you expand? –  Mild Fuzz Feb 8 '11 at 15:33
1  
@Mild Fuzz - Have you tried it yet? If yes, what did it do or not that you didn't want or did want? –  MikeSchinkel Feb 9 '11 at 19:53
add comment

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.