The wp-config.php file is one of the most important files related to your WordPress installation, however, there is so much more to it than just the place your database settings are stored. See what else you have in your WordPress Config file. Frankly, most developers completely overlook many of the awesome features hidden within the wp-config.php file.

This tutorial is designed to showcase some of the lesser-known functions and features that you can make use of with just a few simple lines of code added to your wp-config.php file. Features that are commonly handled by plugins – creating a less-than-clean WordPress installation.

Inside WordPress Config File

Hidden Features Inside WordPress Config File
Hidden Features Inside WordPress Config File

 

Forcing SSL Use For Logins & Admin Backend

When it comes to transmitting passwords and other sensitive information through a browser, an SSL connection is key. As such you might want to enable SSL for your login pages and/or for your WordPress admin backend. Rather than installing any plugins for this, you can accomplish both needs with a few simple lines of code:

/* Force SSL on Login Pages */
define( 'FORCE_SSL_LOGIN', true );

/* Force SSL for Admin Backend */
define( 'FORCE_SSL_ADMIN', true );

Turn Post Revisions On/Off & Set Their Limits

Post revisions can be extremely helpful if you accidentally make the wrong change to a page/post and end up breaking things. However WordPress, by default, doesn’t set a limit on post revisions and this can add up to quite a large database over time. Once again you can easily control this with your wp-config.php file:

/* Turn Off Post Revisions. */
define( 'WP_POST_REVISIONS', false );

/* Set Maximum Number of Revisions. */ 
define( 'WP_POST_REVISIONS', '10' );

Compress Files, Scripts & CSS Styles

These days website performance is extremely important, and WordPress has a slew of built-in compression features that are often overlooked by most:

/* Compress All CSS Files */
define( 'COMPRESS_CSS',        true );

/* Compress All JS Files */
define( 'COMPRESS_SCRIPTS',    true );

/* Turn On GZIP Compression */
define( 'ENFORCE_GZIP',        true );

Control Memory Use

Hidden Features Inside WordPress Config File
Hidden Features Inside WordPress Config File

 

Memory control is usually something that most webmasters will end up dealing with during the course of running a WordPress website. Your website’s wp-config.php file lets you set two different limits. One attempts to set the PHP memory limit – something you would normally do with your PHP.ini file.

The PHP memory limit is set to 30M in default WordPress installs. The other option lets you set the maximum memory that WordPress should use – which is set to 256M by default. Should the need for more memory arise, just add the following lines to your wp-config.php file:

/* PHP Memory Limit */
define( 'WP_MEMORY_LIMIT', '64' );
/* Maximum WordPress Memory Limit */
define( 'WP_MAX_MEMORY_LIMIT', '512' );

Setup A Recycle/Trash Bin For Your Media

Hidden Features Inside WordPress Config File
Hidden Features Inside WordPress Config File

 

Ever deleted a media file and immediately realized you made a massive mistake and had absolutely no backup of that image? This is why WordPress created the Trash bin – something that is enabled by default for Posts/Pages however not for Media items. Luckily this is a quick fix away!

/* Turn On Media Trash. */
define( 'MEDIA_TRASH', true );

Hopefully this tutorial taught you something new, and maybe even helped you get rid of a plugin or two – thus simplifying your WordPress install! As always post any questions you have in the comments below!

Share This Post