useful wp-config variables for WordPress

The majority of WordPress configuration settings are found, and are easily changed, from the WordPress admin panel. But did you know about the settings and options you can enable in the wp-config.php file? Lets run through some that we’ve found useful over time. To use them, place the code into your wp-config file which is found in the root of your WordPress install.

Debugging themes and plugins

To enable PHP error messages for testing you can use WP_DEBUG variable:

1
define('WP_DEBUG', true);

You will then see all PHP errors and notices and can debug accordingly. Remove it when your done; never leave this enabled in a production environment!

Increasing allocated WordPress memory

If you have a lot of plugins installed you may need to give WordPress more memory. Also, if you notice pages getting ‘cut off’ this may be a sign that you don’t have enough memory allocated to WordPress. By default, WordPress is allocated 32MB memory – increase it by adding the variable WP_MEMORY_LIMIT:

1
define('WP_MEMORY_LIMIT', '64MB');

Cleaning up the trash more often

When you delete a post in WordPress it goes into the ‘trash’ section – by default these are kept for 30 days. To change this, use EMPTY_TRASH_DAYS:

1
define('EMPTY_TRASH_DAYS', '60');

You can also set thus to 0 to disable the trash completely.

Disabling the file editor in Admin

Handing over a site to a client? You may not want them to use the built in theme/plugin editor in the backend since they could potentially break things; disable the editor by using:

1
define('DISALLOW_FILE_EDIT', true);

This can also help secure your site if someone evil gains access to a user account!

Changing the duration of Auto-save

You can change the duration at which WordPress auto-saves content – maybe you want it more often (if you make a lot of mistakes or forget to save normally), or perhaps you want to make it auto-save less often to reduce the load on the server. Simply use the AUTOSAVE_INTERVAL variable and set its value in seconds (default is 60 seconds):

1
define('AUTOSAVE_INTERVAL', 120);

Tweaking revisions

The revisions functionality of WordPress can be useful, but does make your database huge. You can tweak the amount of revisions kept by changing the WP_POST_REVISIONS variable:

1
define('WP_POST_REVISIONS', 2);

You can also set this to false to diable post revisions entirely.

Relocating a WordPress install

To move WordPress to a new URL you can use the RELOCATE variable:

1
define('RELOCATE', true);

After setting this, go to the wp-login.php page and then the URL’s will be updated