The wp-config.php file is one of the core files of a WordPress installation. Most users know this file as the key to their WordPress database that holds information like the database name, host, username, password, location, etc. By default, the wp-config.php file is not included in the WordPress installation.

It comes as a sample file known as wp-config-sample.php. This sample file is configured by the user as the actual wp-config.php file to setup the blog. Since the WordPress installation handles this configuration automatically by default, most users are unaware of the fact that the wp-config.php file could be manually configured to specify a wide variety of settings. A few useful WordPress configuration hacks can help you to enhance the performance and improve the security of a blog or website.

Here are a few tricks that could come in handy while configuring the wp-config.php file:

Moving the wp-config.php file

This is more of a security tip than a configuration trick. During initialization, WordPress searches for the wp-config.php file in its root directory. If it’s not found, it looks for it in one directory above the root. So, if you move your wp-config.php file one directory above the root, you could prevent unauthorized access and at the same time, WordPress will work fine.

Changing the Language and Language Directory

The default language in WordPress is English. However, you can change it to any language of your choice by adding the following in the configuration file:

 

  1. Create a language folder in the wp-content folder.
  2. Download your language translation file (.mo) from wordpress.org

Setting Autosave Time Interval

WordPress will auto-save every post in 60 seconds. You can increase or decrease this time interval by adding the following code in the wp-config file:

*X is the desired time interval

Debugging WordPress

There is always a possibility of a loop or a crack to occur while the user is building a site. The debug function in WordPress will help the user to pinpoint what went wrong and where. You can enable the debug function by adding the following code:

Increasing the Memory allocation

While enabling certain plugins, users could encounter “WordPress Memory Exhausted Error”. This is a very common WordPress error caused due to low memory. We could resolve such memory related errors by increasing the memory used by the configuration file. Include the following code in the configuration file:

*64M is the memory size. You could increase it to 128, 256, or 512 depending on the error.

Specifying the Cookie Domain

You specify a cookie domain for your site when you might want to prevent cookies from being sent with requests for static content on sub domains. Including the following code in the configuration file would send cookies only to your non-static domain:

Specifying the Cookie Domain would also boost your performance significantly.

Managing the Trash

The Trash option works just like the recycling bin. All the deleted posts are moved directly to Trash. Over a period of time, all the deleted posts would get piled up in Trash unless you empty it regularly. The trash empties itself every 30 days by design. However, you can change this setting by adding the following code: