Skip to Main Content

One of the most important files in your WordPress installation is the wp-config.php file, located in the root of your installation. WordPress users might think it’s just a place for database configuration stuff, but there are a LOT of options there.  Here are three cool things you can do to modify some of the core WordPress behavior using this critical file.

Automatic Database Optimizing

There are a bunch of plugins that’ll optimize and repair your WordPress database for you on an ongoing bases, but when things hit the fan or if you can’t even login because the database has become so corrupt, your wp-config.php file becomes you best friend.

Added with Version 2.9, WordPress allows admins to enable automatic database optimization support by adding the following define to your wp-config.php file only when the feature is required

define( 'WP_ALLOW_REPAIR', true );

Once enabled, simply go to  /wp-admin/maint/repair.php. You might have to run the script a few times, but it should get things done.

IMPORTANT NOTE: This define enables the functionality, The user does NOT need to be logged in to access this functionality when this define is set. This is because its main intent is to repair a corrupted database, users can often not login when the database is corrupt.  You should set this value to “false” or comment it out when things are back to normal.

Set a Maximum Number of Revisions Saved

WordPress, by default, will save copies of each and every edit made to a post or page, allowing you to revert to a previous version of that post or page.    The saving of revisions can be disabled, but we don’t recommend that.  Instead, just set a maximum number of revisions per post or page.

To set a maximum number of revisions, add the following line to your wp-config.php where the number following the variable is the maximum number.  We might suggest 3 to 5.

define( 'WP_POST_REVISIONS', 3 );

Modify AutoSave Interval

When editing a post, WordPress uses Ajax to auto-save revisions to the post as you edit. That’s great an all, but the autosave feature can often slow things down as well as thrash your database.

You may want to increase this setting for longer delays in between auto-saves. The default is 60 seconds.  We prefer something more like double that.

define( 'AUTOSAVE_INTERVAL', 120 ); // Seconds

For example, Microsoft Word’s default auto-save is every two minutes. That works well enough for us.

Share the love:

Get the Email

Join 1000+ other subscribers. Only 1 digest email per month. We'll never share your address. Unsubscribe anytime. It won't hurt our feelings (much).

Preview Email