Hidden Features Inside WordPress Config File

The wp-config.php file is one of the most important files related to your WP installation, see the hidden features in WordPress config file

By Claudio Pires
Updated on August 7, 2022
Hidden Features Inside WordPress Config File

The wp-config.php file is one of the most critical files related to your WordPress installation. However, there is much more to it than just where your database settings are. See what else you have in your WordPress Config file. Most developers overlook many of the excellent features hidden within the WordPress config file.

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

Inside WordPress Config File

Forcing SSL Use For Logins & Admin Backend

An SSL connection is vital when transmitting passwords and other sensitive information through a browser. You might want to enable SSL for your login pages and/or 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: Hidden Features in WordPress Config File

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 an extensive 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: Hidden Features in WordPress Config File

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 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 typically do with your PHP.ini file.

The PHP memory limit is up to 30M in default WordPress installs. The other option lets you apply the maximum memory that WordPress should use – which is up 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

Setup A Recycle/Trash Bin For Your Media
Hidden Features Inside WordPress Config File

Ever deleted a media file and immediately realized you made a massive mistake and had no backup of that image? This is why WordPress created the Trash bin – which is enabled by default for Posts/Pages but 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, thus simplifying your WordPress install! As always, post any questions you have in the comments below!

Claudio Pires

Claudio Pires is the co-founder of Visualmodo, a renowned company in web development and design. With over 15 years of experience, Claudio has honed his skills in content creation, web development support, and senior web designer. A trilingual expert fluent in English, Portuguese, and Spanish, he brings a global perspective to his work. Beyond his professional endeavors, Claudio is an active YouTuber, sharing his insights and expertise with a broader audience. Based in Brazil, Claudio continues to push the boundaries of web design and digital content, making him a pivotal figure in the industry.