wp-config.php – one most important WordPress files, yet often overlooked. There are a number of great configuration gems you can add to your wp-config.php file to help with debugging, performance, and maintenance that I would recommend looking at if you use WordPress (there is surely something for everyone). All settings are documented: in the WordPress Codex but here are some of my favorite.
- Specify the Number of Post Revisions
define( 'WP_POST_REVISIONS', 3 );
The default is set to 5 but a lower number can decrease database clutter.
- Empty the Trash
define( 'EMPTY_TRASH_DAYS', 15 ); // 15 days
The default is set to 30 but if you are looking to make things tidier – you can easily lower the time between deleting items marked as trash.
- Automatic Database Optimizing
define( 'WP_ALLOW_REPAIR', true );
The default is set not to optimize the database – so putting this in the wp-config will enable optimization.
- Disable the Plugin and Theme Editor
define( 'DISALLOW_FILE_EDIT', true );
The default is set to allow editing. Users want the ability to edit theme and plugin files, but developers know better and know it is just a matter of time before save goes bad. Disallow it.
- Save Queries for Analysis
define( 'SAVEQUERIES', true );
The default is not to save queries. As mentioned before in an earlier post this is a great way to debug and optimize WordPress.
- Redirect Nonexistent Blogs
define( 'NOBLOGREDIRECT', 'http://example.com' );
If this is set when using WordPress Multisite – you can set up a redirect for the browser if the visitor tries to access a nonexistent blog so you can better control traffic.
Overall – there are a number of helpful settings available for you to explore by adding a line or two to to the wp-config.php file. It is well worth your time reviewing your site performance, needs, and data every so often to make sure your site’s performance is the best it can be. Take a few minutes to check out all the options available to you!
There are a ton of great options available for you to put into your wp-config.php file which can help your site run smoother, give you that extra customization you wanted without the use of plugins, and aid in development and debugging.
Here are some highlights that can help save you time and headaches by adding the following to your wp-config.php file:
Help for the Average User
- Change the Autosave Interval: define(‘AUTOSAVE_INTERVAL’, 30 ); (30 = 30 seconds)
- Disable Post Revisions: define(‘WP_POST_REVISIONS’, false );
- Modify Empty Trash Time: define(‘EMPTY_TRASH_DAYS’, 7 ); (7 = 7 days)
- Auto Optimize Your Database: define(‘WP_ALLOW_REPAIR’, true);
- Enable the Cache:define(‘WP_CACHE’, true);
- Define Maximum # of Revisions:define(‘WP_POST_REVISIONS’, 5);
Help for Developers
- Output Errors:define(‘WP_DEBUG’, true);
- Save Queries for Analysis:define(‘SAVEQUERIES’, true);
- Define WP Site URL (override settings):define(‘WP_SITEURL’, ‘http://’ . $_SERVER[‘SERVER_NAME’] . ‘/path/to/wordpress’); – great for moving sites from one host to another when the actual domain name is not yet available
- Define WP Home (override settings):define(‘WP_HOME’, ‘http://’ . $_SERVER[‘HTTP_HOST’] . ‘/path/to/wordpress’); – great for moving sites from one host to another when the actual domain name is not yet available
Full documentation is available: http://codex.wordpress.org/Editing_wp-config.php