Quickly Enable Debug Mode On WordPress Website When Needed


If you have ever faced “WordPress white screen of death” then you probably already know that there is something wrong on your website and in situations like this, you must switch ON WordPress debug mode on your website to diagnose the issue. But to enable debug mode, you will require to edit WordPress configuration file on your production server. And sometimes it’s little too much trouble to access web server and modify wp-config.php file, just to enable debug mode. Well, there is a little hack, we can use that can quickly switch on debug mode on the fly, without even editing configuration file every time.

This little hack was shared by Joost de Valk on his blog. You must paste the following code snippet in your WordPress configuration file (wp-config.php). It wouldn’t work by adding this code in functions.php since it’s already too late to define WP_DEBUG there.

// enable debug mode
if ( isset( $_GET['debug'] ) && 'secret-key' == $_GET['debug'] ) {
    define( 'WP_DEBUG', true );
    define( 'SCRIPT_DEBUG', true );

Now you can open any page, and if something goes wrong there, like a white screen of death, you can add ?debug=secret-key to its URL and can access the debug logs and know what’s causing the trouble.

It’s important to note that anyone can access this information if they know your secret-key, so it would be wise to change that phrase ‘secret-key’ to a key of your own choosing, so not everyone out there can enable debug mode on your blog.


Leave a Reply

Random Post Selection ::

Recent Posts

Unlock Unlimited Downloads