Answers for "how to redirect a page url in wordpress"

PHP
1

wp_redirect to home page

function redirect_to_home() {
  if(!is_admin() && is_page('2')) {
    wp_redirect(home_url());
    exit();
  }
}
add_action('template_redirect', 'redirect_to_home');
Posted by: Guest on October-02-2020
0

wp php redirect my account page url to custom url

function custom_redirect() {
    global $wp;

    if( $wp->request == 'my-account' ) {
        wp_redirect( site_url( 'my-account/orders/' ) );
        exit;
    }
}

add_action ('template_redirect', 'custom_redirect');
Posted by: Guest on October-18-2021

Code answers related to "how to redirect a page url in wordpress"

Browse Popular Code Answers by Language