WordPress Code Snippets

A fresh mix of code snippets and tutorials

WordPress wp-config.php tricks


A concise collection of wp-config.php tricks from my WordPress sites to yours.


All of my sites include the following constant definitions:

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:

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.

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:

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 wp-config.php file:

As-is, this sets the WP Memory Limit to 64 MB, and you certainly can change that to whatever value works.

FTP Credentials

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 wp-config.php file:

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.

Multisite Stuff

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 wp-config.php:

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:

You don’t need to include both of these; only one is necessary. I’ve included both to show usage of the ABSPATH constant.

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 wp-config.php:

Placing this line in wp-config.php is equivalent to removing the edit_themes, edit_plugins and edit_files capabilities of all users.

More tricks..

Check out DigWP.com for more wp-config tricks!

Learn more

WordPress Themes In Depth

Show Support

Like our new Facebook Page to show support!