WordPress Developer Debug.

When developing themes and plugins for WordPress I often find myself with the dreaded white page – or just half a page with no useful error information.

You may already know about the WP_DEBUG constant, if you don’t its found in your wp_config.php file and you just change it to…

define('WP_DEBUG', true);

to turn it on debugging.
Chances are that with this turned on your WordPress will start spewing out a load of warnings you never even knew were happening!

This ‘error noise’ is fine for a development site. But what about if your site is live and need to code a new feature?

I came up with this little trick so I can turn on debug mode in the page request.

$debugmodeon = false;
if (isset($_GET['debug'])) {
	if ($_GET['debug'] != "") { 
		$debugmodeon = true;
	}
}
define('WP_DEBUG', $debugmodeon);

Just add ?debug=true and voilà – debugging info only when you need it 😉

Once your done – you’ll want to swap back to define('WP_DEBUG', false); so your ‘debug mode’ can’t be triggered by accident..

Author: Sable

Site owner. Just me - nothing more, nothing less.

2 thoughts on “WordPress Developer Debug.”

Leave a Reply