Created
April 5, 2012 02:06
-
-
Save pgooch/2307423 to your computer and use it in GitHub Desktop.
Wordpress Redirects with wp_redirect()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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