10+ wp-config tricks to boost your WordPress site

If you already installed WordPress, you know the wp-config.php file: this is the file where you set up your database connection info and define your site language. But you can do a lot more things with the wp-config.php file. In this article, I'll show you 10+ tricks, using wp-config.php, to boost your WordPress website.

Prevent WordPress from asking FTP credentials

Paste the following line in your wp-config.php file. This file is located in the root of your WordPress install.

define('FS_METHOD', 'direct');

Please note that the code snippet provided above might not work on all hosting providers, and might even cause security issues if your host is badly configured, so avoid using it if you’re not sure about your hosting.

I use VidaHost on CatsWhoCode, WPRecipes and my other blogs. WP Web Host is also good for smaller websites.

Source: http://wp.tutsplus.com/tutorials/security/conquering-the-wp-config-php…

Tell WordPress to remember your FTP credentials

If the above method do not work on your server, or if you don’t want to implement it for some reason, here is another useful snippet. This one simple tells WordPress to remember your FTP credentials so you won’t be asked again when an upgrade is available.

define('FTP_HOST', 'ftp.yoursite.com');
define('FTP_USER', 'Your_FTP_Username');
define('FTP_PASS', 'Your_FTP_password');
define('FTP_SSL', true); // If you can use a SSL connection set this to true

Source: http://admindaily.com/how-to-stop-wordpress-ftp-to-upgrade-plugins.html

Disallow direct file edition

By default, WordPress allows the site administrator to directly edit themes and plugins files through a built-in editor. This is very useful, but if you’re building a site for a client you probably don’t want him to break the site. Here’s a simple way to disallow direct file edition.


Source: http://www.wprecipes.com/how-to-hide-theme-editor…

Automatically empty trash

If you want to define how often the trash should be automatically emptied, here’s the right way to do it:

define('EMPTY_TRASH_DAYS', 1);

Replace 1 by X to empty spam comments automatically every X days. That’s simple as that!

Source: http://www.wprecipes.com/how-to-automatically-empty-trash-on-a-daily-basis

Easily move your WordPress install

WordPress supports an automatic relocation method intended to be a quick assist to getting a site working when relocating a site from one server to another.

To move your WordPress website easily, paste the following line into your wp-config.php file and then follow the steps explained on WordPress Codex.


Source: http://wp.tutsplus.com/tutorials/security/conquering-the-wp-config-php-file…

Increase WordPress memory limit

By default, WordPress is configured to limit the php memory it uses to 32M. If you receive a message such as “Allowed memory size of xxxxxx bytes exhausted”, you might want to increase this limit, as shown below:

define('WP_MEMORY_LIMIT', '96M');

Source: http://digwp.com/2010/08/pimp-your-wp-config-php…

Automatic database repair

Added with Version 2.9, there is automatic database optimization support, which you can enable by adding the following define to your wp-config.php file only when the feature is required.

define('WP_ALLOW_REPAIR', true);

Source: http://digwp.com/2010/08/pimp-your-wp-config-php…

WordPress debugging, the easy way

When developing or debugging, it is useful to display errors. But when your site is live, you might not want to show your potential errors to the entire world. Here is simple solution to display errors only when a debug=debug parameter is found on the url.

The first thing to do is to paste the following code into wp-config.php:

if ( isset($_GET['debug']) && $_GET['debug'] == 'debug')
  define('WP_DEBUG', true);

Once done, simply add a GET parameter to the url of the page you’d like to debug, as shown below:


Source: http://yoast.com/wordpress-debug/

Force SSL usage on your wp-admin directory

If you’re running WordPress on a server that supports SSL, you might want to force SSL usage on all admin sessions. To do so, simply define the FORCE_SSL_ADMIN constant in your wp-config.php file, as shown below:

define('FORCE_SSL_ADMIN', true);

Source: http://www.wprecipes.com/how-to-force-using-ssl-on-wp…

Block external requests

Since version 2.8, WordPress allows you to define constants to control access to specific hosts from behind a proxy server.

define('WP_HTTP_BLOCK_EXTERNAL', true);

It will block external requests from that time on. Though, some plugins need external request to work properly. If you experience problems, you can define a whitelist by pasting the code below into wp-config.php. Don’t forget to replace my url by the one needed by the plugin, and note that you should allow access to api.wordpress.org in order to ensure proper functionality of core files and plugins.

define('WP_ACCESSIBLE_HOSTS', 'wprecipes.com');

Source: http://www.wprecipes.com/block-external-requests-on-your-wordpress-blog

Define website url

Introduced in WordPress 2.2, WP_SITEURL and WP_HOME overrides the wp_options table value for home but does not change it permanently, which can be very useful when you move a website to a new domain.

define('WP_HOME', 'http://catswhocode.com'); 
define('WP_SITEURL', 'http://catswhocode.com');  

Source: http://digwp.com/2010/08/pimp-your-wp-config-php…