If you have a problem with your WordPress website or blog, how do you fix it? There are many possibilities and one you should be aware of is a secret built-in repair and optimise tool.
If you have a WordPress website you may have been lucky and never had a problem. Every core update may have gone smoothly and every plugin has updated without problems. Your server might never have gone down. It does happen.
However, not everyone is this lucky and sometimes problems do crop up and they are often after a WordPress core update or when plugins are updated. Sometimes things go wrong for no obvious reason and files or database can become corrupted.
How do you solve website problems?
You should always protect your site by making regular backups and if you are not sure how to do this, read Don’t get caught without a backup of your WordPress website. A backup enables you to put your site back to a time when it was working properly. The only downside is that you will lose any posts or site changes made since the backup was made.
Another option you should be aware of is the built in WordPress repair tool. The focus of this is the databases that WordPress uses to store its data. Those databases contain everything that is important to the site and it will not work properly if they become corrupted.
It may be possible to fix whatever problem you are having with your site using the repair tool. Most problems are caused by plugins and the repair tool cannot fix those, but if you know they are OK and suspect the problem is something to do with the WordPress database, try this fix.
Secret WordPress repair tool
To access the WordPress repair tool go to the following URL:
www.yoursite.com/wp-admin/maint/repair.php
Your site will most likely respond with this message:
The tool is disabled by default and it must be enabled by adding
define(‘WP_ALLOW_REPAIR’, true);
to the wp-config.php file. This probably looks like gibberish to you if you are not familiar with the workings of WordPress and editing files on the server but there is an easy solution as we will see in a minute.
Let’s assume you have somehow added that code to the WordPress configuration file. This is what you would see when you go to the URL on your site:
There are two buttons and the database can be repaired or it can be repaired and optimised. It seems like a good idea to optimise the database at the same time. A big site with thousands of pages could take a long time, but most people should find that it runs quite quickly on their modestly sized site.
This tool could fix a problem with your site and it could make it faster thanks to the optimisation. It is not something that should be run every week to speed up your site, but make a mental note about where the tool is and how to use it should the need arise.
Remove that line you added to the wp-config.php file to disable the tool after it has been used.
Now that we know where the repair tool is and how to use it, we need to know how to enable it.
How to edit WordPress wp-config.php file
The geek method: There are several ways to add the code to the wp-config.php file and if you have ftp access to your website, fire up your ftp program and download the file from your web server to your computer. Open it in a plain text editor like BBEdit on the Apple Mac or Notepad+ on Windows PC, and add define(‘WP_ALLOW_REPAIR’, true); to the end of the file. Save it and upload it again, overwriting the original file. Read about ftp programs in how to access WordPress site files and fix faults with FTP.
If your web host provides cpanel access to your website, an alternative method is to log in, go to the File Manager and run it to access the files on the web server. There is an Edit button to open files in a text editor and you can then type that command at the end and save it.
The easy method: Use a plugin! Whatever you need to do on a WordPress website there is usually a plugin that can help and in this case it is WP Config File Editor.
- Go to Plugins in the sidebar
- Click the Add New button
- Enter WP Config File Editor into the search box
- Click the Install Now button next to WP Config File Editor
- Click the Activate button
Once installed and activated, here is how to use it:
- Click WPCF Editor in the sidebar
- Click the Database tab
- Tick the Automatic Repair checkbox
- Click Save
Do not change anything else in WPCF Editor and don’t be tempted to poke around and try some of the other things. There are a lot of advanced features that, if misused, could cause problems with your site and you need to know what you are doing.
When the Save button is clicked, a message like this appears:
Open a new tab and check that your website is OK. If it is not, click the Restore Backup link. This simple Automatic Repair tweek will not cause problems, but you should check your site anyway. If it is OK, click the close or Done buttons.
Now you can use the WordPress repair tool at:
www.yoursite.com/wp-admin/maint/repair.php
Clear that checkbox afterwards to disable the repair tool and save the change.
It is unlikely, but possible for the wp-config.php file to be locked to stop people meddling with it. If this happens, go to WPCF Editor and click Tools in the top left corner. Select System Check in the menu and then click Turn On under Writable wp-config.php.
The WordPress Config File Editor plugin lets you get geeky and edit the wp-config.php directly like this:
Go to the last line of the file and enter the code to allow the repair tool to run. Use it and then return here afterwards and delete the line you added.