I wanted that when i access my site with specific parameter, my site used a different theme at that moment (only temporarily, to show only to me as a preview). I want it for test purposes. Is there any way to do/activate that using php codes?
2 Answers
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' );