Skip to content

Instantly share code, notes, and snippets.

@pgooch
Created April 5, 2012 02:06
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pgooch/2307423 to your computer and use it in GitHub Desktop.
Save pgooch/2307423 to your computer and use it in GitHub Desktop.
Wordpress Redirects with wp_redirect()
// The Base Function
wp_redirect('http://www.urlofsite.com/path/to/location',301);
/* This needs to be run on an action, or at least I wanted able to get it to run outside of an action, I suggest template_redirect */
// In Use Example
add_action('template_redirect', 'redirect');
function redirect(){
if($redirect){
wp_redirect(get_bloginfo('url').'/wp-content/plugins/redirector/site/index.php',302);
exit;
}
}
/* Post: http://www.fatfolderdesign.com/564/wordpress/redirecting-users-in-wordpress-with-wp_redirect */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment