Software Developer

Optimized wp-config.php File

These are settings which I always add to a WordPress “wp-config.php” file. I call these “optimized wp-config settings” because they keep the site somewhat more optimized than the default settings.

Here are my favorite wp-config settings, followed by a description of each one.

define( 'WP_POST_REVISIONS', false ); // Disable revisions that swell up your database
define( 'AUTOSAVE_INTERVAL', 240 ); // Seconds
define( 'EMPTY_TRASH_DAYS', 5 ); // Empty trash every 5 days
define( 'WP_CACHE', true );
define( 'IMAGE_EDIT_OVERWRITE', true );
define( 'DISALLOW_FILE_EDIT', true ); // discourage hackers

These settings go inside the wp-config.php file in the root of a WordPress installation.

  1. Setting WP_POST_REVISIONS to false disables the saving of every single revision that you make to posts. Saving every single post revision would swell up and bloat your database.
  2. I increase the AUTOSAVE_INTERVAL to 240 seconds because the default is 60 seconds. This is how often WordPress is saving your post while you are editing it. (Please note that if you are a journalist or career blogger, you probably do not want to do this! You may even want to decrease it to maybe 30 seconds. Revisions are good for journalists and career bloggers since an automatically saved revision could save you headaches and rewriting if your computer were to crash while you were writing.)
  3. The EMPTY_TRASH_DAYS settings lets you tell WordPress when to automatically permanently delete posts, pages, attachments, and comments from the trash. By default, WordPress empties the trash every 30 days. The example below sets EMPTY_TRASH_DAYS to ‘5’ which tell WordPress to empty the trash every 5 days.
  4. Some cache plugins will automatically add the WP_CACHE setting, but I use one that requires me to add this line manually. Setting WP_CACHE to true enables the WordPress cache system.
  5. Setting IMAGE_EDIT_OVERWRITE to true makes sure that WordPress will delete old copies of images that you create if you edit images in the admin. If you don’t sent the IMAGE_EDIT_OVERWRITE to true, WordPress will store all old copies of image edits even after you restore the original image and no longer need the old edits.
  6. Line 6 is about security rather than optimization. (Users with access to your admin could still install new plugins and themes, so I’m not sure how much security this setting adds.) Setting DISALLOW_FILE_EDIT to “true” will disable the ability to edit theme files and plugin files in the WordPress admin back end. This DISALLOW_FILE_EDIT setting makes your WordPress site somewhat more secure because if someone does hack your WordPress back end, they will not be able to edit plugin or theme files.

See more:

By

Questions and Comments are Welcome

Your email address will not be published. All comments will be moderated.

Please wrap code in "code" bracket tags like this:

[code]

YOUR CODE HERE 

[/code]