A concise collection of
wp-config.php tricks from my WordPress sites to yours.
All of my sites include the following constant definitions:
define('WP_DEBUG', false); define('WP_DEBUG_LOG', false); define('WP_DEBUG_DISPLAY', false); define('SAVEQUERIES', false);
This set of constants makes it easy to toggle “debug mode” off and on. Specifically, when it’s time to debug stuff, I change the first two constants to
true, and then change them back to
false when finished debugging.
For reference purposes, here are some additional wp-config snippets that I’ve used in the past:
@ini_set('log_errors', 1); @ini_set('display_errors', 0); @ini_set('error_log', ABSPATH . '/debug.log');
If I recall, these were useful in setting up error logging in an otherwise limited shared hosting environment. Just FYI mostly, best to use the WP definitions instead of these workarounds.
Updates, Revisions, and Trash
I also include the following constants, which disable auto-updates, post-revisions, and automatic trash deletion.
define('WP_AUTO_UPDATE_CORE', false); define('WP_POST_REVISIONS', false); define('EMPTY_TRASH_DAYS', 999999);
Check out Disable WordPress Automatic Updates for more ways to disable auto-updates (for plugins and themes).
Site URL and Home URL
Although not really necessary, I also like to define the Site URL and Home URL constants:
define('WP_SITEURL', 'https://example.com/wp'); define('WP_HOME', 'https://example.com');
These constants are used for the General Settings, “WordPress Address (URL)” and “Site Address (URL)”, respectively. Including these definitions helps to prevent “accidents” on multi-author blogs.
WP Memory Limit
If you are experiencing “out of memory” or similar errors, try adding the following definition to your site’s
As-is, this sets the WP Memory Limit to 64 MB, and you certainly can change that to whatever value works.
When using WordPress’ one-click update feature, it’s a bit tedious having to reenter your FTP credentials every single time. Fortunately, WordPress lets you define your creds as constants in the
define('FTP_USER', 'username'); define('FTP_PASS', 'password'); define('FTP_HOST', 'localhost');
Of course here you should replace the constant values with your actual credentials. In most cases, “localhost” is the correct value and does not need changed.
I try to avoid WP Multisite, but when a client or something needs to set it up, I’ll add the following constant definitions to
define('WP_ALLOW_MULTISITE', true); $base = '/wp/'; define('MULTISITE', true); define('SUBDOMAIN_INSTALL', false); define('DOMAIN_CURRENT_SITE', 'example.com'); define('PATH_CURRENT_SITE', '/wp/'); define('SITE_ID_CURRENT_SITE', 1); define('BLOG_ID_CURRENT_SITE', 1);
Make sure to check the WP Codex to verify current definitions and correct values for these constants. Stuff changes all the time.
Uploads Directory Path
On certain sites, one-click updates and media uploads do not work as advertised, but in some cases adding the following definitions to
wp-config.php does the trick:
define('WP_TEMP_DIR', ABSPATH .'wp-content/uploads/'); define('WP_TEMP_DIR', '/abs/path/to/example.com/httpdocs/wp-content/uploads');
You don’t need to include both of these; only one is necessary. I’ve included both to show usage of the
Disable File Editing
By default, WordPress enables admin-level users to edit plugin and theme files from within the WP Admin Area (under Appearance > Editor). I like to disable this functionality to help contain any security breach, and also because I never use it. To disable file editing from within the Admin Area, add this line to
Placing this line in
wp-config.php is equivalent to removing the
edit_files capabilities of all users.
Check out DigWP.com for more wp-config tricks!