Home > Tutorials > Wordpress Tutorials > Hidden Features Inside Your WordPress Config File

Hidden Features Inside Your WordPress Config File

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. 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.

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 quiet 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

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

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!

About Michael Boguslavskiy

Michael Boguslavskiy is a full-stack developer & online presence consultant based out of New York City. He's been offering freelance marketing & development services for over a decade. He currently manages Rapid Purple - and online webmaster resources center; and Media Explode - a full service marketing agency.

Check Also

Looking to Fortify Your WordPress Website’s Security? Try MalCare Security Plugin!

30% of sites on the internet are being powered by WordPress today – making it ...

Like every other website, this site uses cookies to analyze our traffic. Cookies may also be utilized by our advertisers and partners. By using this website you agree to the use of said cookies. More Information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings, continuing to navigate past this message, or you click "Accept" below then you are consenting to the use of cookies on the Rapid Purple website.