wordpress admin redirect code example

Example 1: redirect wordpress

add_action( 'template_redirect', 'redirect_to_other_page' );
function redirect_to_other_page() {
    if ( is_page( 143 ) ) {
	  
      wp_redirect( '"'.home_url().'/services/messenger/"', 301 );
      ///wp_redirect( 'example.com/page', 301 ); 
    exit;
    }
}

Example 2: wp-admin redirecting to the https wordpress

So if you are having this issue only when you go to ../wp-admin then it is 
because you have force ssl admin set to true. You can find this in 
wp-config.php in the root of your WordPress site, you need to set this option 
to false.

define('FORCE_SSL_ADMIN', false);

I am assuming your siteurl in the wp_options table in the WordPressdatabase is 
set to a http:// address.

Tags:

Misc Example