WordPress redirect the home page to another page

WordPress redirect the home page to another page

It is relatively easy to redirect the WordPress homepage to another page. The redirection is possible to a static file as well as to an internal or external URL.

For this, the following code must be added in the functions.php of the corresponding template:

add_action('template_redirect', 'default_page');
function default_page(){
    if(is_home() or is_front_page()){
       exit( wp_redirect("https://www.lautenbacher.io"));
    }
}

Of course, the URL in the above example must be adjusted accordingly. After that, the redirect should be active immediately.

Leave a Reply

Your email address will not be published. Required fields are marked *