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.
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.
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
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.
Automatically empty trash
If you want to define how often the trash should be automatically emptied, here’s the right way to do it:
Replace 1 by X to empty spam comments automatically every X days. That’s simple as that!
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.
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:
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.
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
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:
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:
Block external requests
Since version 2.8, WordPress allows you to define constants to control access to specific hosts from behind a proxy server.
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 website url
Introduced in WordPress 2.2,
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');