using wp_redirect to redirect wordpress pages using wp_redirect to redirect wordpress pages wordpress wordpress

using wp_redirect to redirect wordpress pages


You may want to put your redirect code into a callback function that is tied to the template_redirect hook. Put code similar to the following in the functions.php file of your theme. The function named "some_condition" (which you write) will determine if the page should be redirected or not.

add_action( 'template_redirect', 'my_callback' );function my_callback() {  if ( some_condition() ) {    wp_redirect( "http://www.example.com/contact-us", 301 );    exit();  }}