Skip to main content
SnippetsWordpress

Switch Theme by IP Address

By September 1, 2019April 11th, 2020No Comments

Simple way to allow yourself the convenience of editing a live development theme where you want some privacy while working out a bug etc. Just drop this into functions or a plugin and include your IP. Works great.

$developers_ips = array(
"255.255.255.255",
);
 
//check if the visitors ip is inside the list of developer ip's
if(in_array($_SERVER['REMOTE_ADDR'], $developers_ips)){
 
        //theme visible to developers
	switch_theme( 'theme-directory' );
 
} else{
 
        //theme that's visible to the public
	switch_theme( 'theme-directory' );
	
}
https://www.craig-edmonds.com/how-to-show-a-different-wordpress-theme-based-on-ip-address-solved/

Contact us to learn more about Adopt the Web for your business

Author Jarod Thornton

More posts by Jarod Thornton