Wordpress Redirects with wp_redirect()


/ Published in: PHP
Save to your folder(s)

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. More information at the link.


Copy this code and paste it in your HTML
  1. // The Base Function
  2. wp_redirect('http://www.urlofsite.com/path/to/location',301);
  3.  
  4. // In Use Example
  5. add_action('template_redirect', 'redirect');
  6. function redirect(){
  7. if($redirect){
  8. wp_redirect(get_bloginfo('url').'/wp-content/plugins/redirector/site/index.php',302);
  9. }
  10. }

URL: http://www.fatfolderdesign.com/564/wordpress/redirecting-users-in-wordpress-with-wp_redirect

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.