If you want to redirect all the posts and pages on a WordPress site to the home page, all you need is access to functions.php file.

  • Custom WP

Functions.php files are located in the your theme directory. If you have access to you functions.php file, just copy and paste this code and all users will be redirected to your website home page.

add_action( 'template_redirect', 'redirect_to_homepage' );

function redirect_to_homepage() {
    $homepage_id = get_option('page_on_front');
    if ( ! is_page( $homepage_id ) ) {                                                                                  
         wp_redirect( home_url( 'index.php?page_id=' . $homepage_id ) ); 

Redirect WordPress