Skip to content

Instantly share code, notes, and snippets.

@trepmal
Created July 22, 2015 23:51
Show Gist options
  • Save trepmal/18b4d1ec72bd2cf16753 to your computer and use it in GitHub Desktop.
Save trepmal/18b4d1ec72bd2cf16753 to your computer and use it in GitHub Desktop.
<?php
function tmp_change_home_url( $homeurl ) {
$old = 'example.com';
$new = 'newsite.com';
if ( strpos( $homeurl, $old ) !== false ) {
$homeurl = str_replace( $old, $new, $homeurl );
}
return $homeurl;
}
add_filter( 'home_url', 'tmp_change_home_url' );
#depending on scope, may need these...
#add_filter( 'site_url', 'tmp_change_home_url' );
#add_filter( 'admin_url', 'tmp_change_home_url' );
#add_filter( 'login_url', 'tmp_change_home_url' );
#add_filter( 'redirect_canonical', 'tmp_change_home_url' );
#add_filter( 'wp_redirect', 'tmp_change_home_url' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment