Site Overlay

Quick address switch in WordPress

WordPress is, by all means, a wonderful piece of software. Like all beautiful things, when you are looking at things very closely, you tend to find the little odd and end that seems to be off track.

One of the most “annoying” aspects of WordPress is when you, for example, have to run a copy of a site in a different URL. I like to run my sites on a site when I am working on them. This makes development easy and responsive and allows me to screw up here and there without the worry of having to put the site offline or in maintenance mode.

Usually you need to update the wp_config table, changing the URLs in the database of your local development machine, which is a hassle. Another quick fix, is to, instead of pointing your local site to, is to actually change your hosts files, so that they point to your local machine. Obviously that becomes a headache if you need to check out the original site every now and then.

Finally, one way I have found is by adding this simple little snippet to your functions.php file:

// where you want your site to point to
$_base_url = "";

// set the constants

// actually update the tables.
// once this is run once, ou can comment the lines for increased performance.

Hope this comes in handy.



2 thoughts on “Quick address switch in WordPress

Leave a Reply

Your email address will not be published.