Really useful WordPress wp-config tweaks

WordPress is one of the most popular CMS Management Tool to create a blog or website. Among many other files on WordPress root directory, wp-config is the one of the most important one as it contains database connection and configuration details. This file is created itself after the 5 minute worpress installation.

This posts discusses on some really useful -config Tweaks.

Considering you’ve a website up and running on WordPress, follow these simple steps:

Download wp-config-sample file from your root directory using ftp

Open it using Dreamweaver or any other available editors (including Notepad++/Bluefish)

Choose and add codes that you find useful from below

Upload the edited wp-config-sample to root directory, rename it to wp-config (overwrite any changes)

You can also edit wp-config.php instead of wp-config-sample.php, but make sure to back it up first.

WordPress post revision system saves a copy of your posts and pages every time you update it. This is really useful as you can quickly browse and revert back to older versions of your post and pages without any hassle. But the problem is there’s no limit to no. of revision posts by default which may greatly increase size of your site’s database.

You can limit the no. of post revisions by adding following code in wp-config file. Revision post limit for Deependra’s Blog! is 2. You can also change <2> to <false> if you want to disable post revisions.

Code

define( ‘WP_POST_REVISIONS’, 2 );

Empty your WordPress Trash : define( ‘EMPTY_TRASH_DAYS’, 5 );

When you delete posts, pages, comments, images or comments, it isn’t permanently deleted. Instead, it is sent to Trash folder. If you want to save time from having to delete it permanently from this folder, then add this code to wp-config file. Here <5> is the no. of days specified to automatically empty Trash folder. You can change this number or disable this feature by adding <0>.

The default time interval for posts auto save in WordPress is 60 seconds. You can increase or decrease this Time Interval according to your need with the help of following code snippet. (The Time interval is in seconds.)

If you want to prevent users from editing your plugin and theme files which may even result in site crash, then adding this code could be really helpful. This code also provides an additional layer of security if a hacker gains access to a well-consent user’s account.

You may have your own reason to disable this feature. Whether it may be because of your host or maybe because you like to update your wordpress files manually! Add this code snippet to disable WordPress automatic update feature.

Code

define( ‘AUTOMATIC_UPDATER_DISABLED’, true );

Explore more about wp-config and other codes that may be useful to you here.