WordPress Trick for Local Configuration

When developing WordPress Site, sometime you may need to have more than one configuration such as different Database settings.  For example, I may have one database setting for my local machine and one for my webserver.  There are many ways to handle that, and my trick is this:

First create a file called local-config.php

Then in wp-config.php, modify little bit:

The magic here is you only keep local-config.php in your local machine.  When WordPress starts, it will try to locate local-config.php under the same directory of wp-config.php.  If it successfully located the file, it will use the configuration in local-config.php instead.  Otherwise, default config for your deployment server will be used if that file is not found.

You can apply the same logic for different environment settings.  :-)