Activate different theme for temporary preview

You can Detect Server Remote Address and if it matches with your IP then you can use different theme following way.

function wp_set_preview_theme( $current_theme ) {
    if ( 'YOUR_IP_ADDRESS' === $_SERVER['REMOTE_ADDR'] ){
        // Use your preview theme instead
        return 'THEME_YOU_WANT_TO_USE';
    } else {
        // Otherwise, keep the current theme
        return $current_theme;
    }
}

add_filter( 'stylesheet', 'wp_set_preview_theme' );
add_filter( 'template', 'wp_set_preview_theme' );

Leave a Comment