How to Break a WordPress Install (And Fix It Again)


WordPress is pretty powerful but, sometimes, even this robust CMS can fall victim to humans fiddling with the settings and breaking it. This tutorial and screencast looks at the most common way to break WordPress and what you can do about it.

Changing the Site URL

Sometimes it's tempting to change the Site URL to reflect a change in your domain name. For example, if you're moving from to, a lot of people who are new to WordPress consider their best, easiest option to be changing the site URL in the Dashboard.

It is important that you do not do this!

This will break your install!

So you've already done it? Not to worry. It's pretty easy to fix. There are actually three ways to fix it.

Option 1 Edit the functions.php File

The first way of fixing your WordPress install is the one preferred by most people. In case you're not familiar with the purpose of a functions.php file, it is mostly used to extend the abilities of your WordPress install or to clean up the code that powers your theme. Your functions file will be different to almost every other theme around.

It doesn't matter too much what is in it because you'll only be using the first couple of lines.

Open up the functions.php file in your theme directory (twentyeleven, etc.). Then at the very top of the file, just after the opening line, put the following in:

	update_option( 'siteurl', '' );
	update_option( 'home', '' );

Reload your site and it should be fixed. Open up your General dashboard settings and make sure that your Site URL reads as it should (what it was before you edited it).

Important: Don't forget to go back to your functions.php file and remove the lines you just added in. Otherwise you'll keep breaking your site as WordPress will continue to attempt to rewrite the contents of that Site URL field.

Option 2 Edit the wp-config.php File

Another option for resetting the value of your Site URL field, is to update the wp-config.php file which is in the base directory of your site.

Many people, including WordPress' own user manual (The Codex), say that this is not the best choice for resetting the Site URL because it 'hard codes' the Site URL into your WordPress install and doesn't allow you to change it in the Dashboard afterwards.

However, remember how you got into this mess in the first place! It was through someone (or yourself) editing that value thinking it was an easy fix. It might be handy to blank out the option to change it in future.

Additionally, if for some reason Option 1 has failed you, you've really got little choice but to give this a go too!

Open up your wp-config.php file in your editor of choice and look for the line which says: "That's all, stop editing! Happy blogging.". Just below that line, paste in the following, again changing the site URL to whatever your Site URL should be.

	define( 'WP_HOME', '' );
	define( 'WP_SITEURL', '' );

Reload your install and it should be fixed. With this method, you may need to type your Site URL into the browser and try to log in using the wp-admin page e.g.

Option 3 Relocate, True!

The final way to easily update your Site URL to the correct one is to use WordPress' inbuilt relocate method. This one couldn't be simpler and is very much like the previous method.

Open up your wp-config.php file again and this time, you need to add the following code just above the "That's all, stop editing! Happy blogging." line.

	define( 'RELOCATE', true );

Hey Presto! Your site has found itself again. Just that simple line of code has done a lot (hopefully) to fix your blog. It has updated the appropriate fields within the WordPress database.

Important: Don't forget to go back to your wp-config.php file and remove the line you just added in. Alternatively, if you think you might make the same mistake again in future, you can just change the word 'true' to 'false' (without the speech marks). That way, next time someone changes your Site URL, you can just briefly change it to 'true' again.

That's It!

In conclusion, it's best not to update the Site URL on your blog. If you want to move your site, the best process is to make a backup of your database and theme, before moving the theme files by hand and then importing your existing database into the new Install of WordPress on your new domain name.

Related Posts
  • Code
    Web Development
    How to Use New Relic With PHP & WordPressRelic retina preview
    Today we will look at how to monitor a PHP application using New Relic. More specifically we will set up a basic WordPress installation and get some performance data about it, in the New Relic dashboards.Read More…
  • Code
    5 Quick Beginner-Friendly CSS Customizations That Make Your Blog Stand OutCssblog
    In this tutorial, we'll cover how to do five quick CSS customizations that make your blog stand out. Even if you don't know what CSS is, you'll be able to follow the instructions and change the standard look of your theme.Read More…
  • Code
    An Introduction To Deploying WordPress with MinaImage400
    As a PHP application, WordPress is usually deployed by a very old method: uploading files via FTP. We have some deployment tools, but they often requires some type of Ruby skill. For example, one popular, powerful tool is Capistrano, but it's also very heavy with many Ruby/Rails related features. I also think that it's little bit tricky to install Capistrano for a PHP developer without any Ruby knowledge. So what options do we have as WordPress developers? In this tutorial, I will introduce you Mina: A small, light tool aims to fast deployment and server automation.Read More…
  • Code
    WP101 Training
    How to Customize Your WordPress Theme With a Child ThemeHow to customize your wordpress theme with a child theme 2
    So you have a WordPress theme on your website, either a free one or a commercial one, and you want to customize it. Someone has wisely recommended you do this by "creating a child theme". But what does that mean, and how do you do it?Read More…
  • Code
    Imposing SSL and Other Tips for Impenetrable WP SecurityImposing ssl and other tips for impenetrable wp security b
    Internet security has always been as important as your personal security. If you are making money through your blog or website, the security of your website becomes as critical as securing your bank account. Luckily, WordPress strives to ensure better security with every new version. Besides, there are plenty of plug-ins you can use to fortify your website or blog’s security. However, not all users, including developers, are as security savvy as they can and should be. The most interesting part is that optimizing a WordPress blog/website for better security requires only small tweaks, most of which are previously covered in one of our posts. Today, we share a few more interesting and effective tips to help you secure your website/blog against information theft, breaches, intrusions and interception.Read More…
  • Code
    Conquering the wp-config.php File - 11 Good PracticesThumb 200
    There are 981 files and 95 folders which come with the WordPress (v3.4.1) package. None of these files need manual modification, except the wp-config.php file. Of course, we don't have to edit the file if we're fine with the default WordPress configuration but it's essential that we learn how to conquer the file in order to apply security precautions, speed tricks and other stuff which we will be studying in this article.Read More…