Index of /Andrej Ciho/Old Blog/WordPress/Debugging a live WordPress site using WP_DEBUG

Back Parent Directory 2012-01-26 20:39

WP_DEBUG is a boolean constant found in wp-config.php. When set to true, all php errors (and warnings and notifications) are printed in the browser. This is very useful during development but can be dangerous because text of php errors often reveals unnecessary details about your programming code, paths, etc to visitors in case they run into an issue with your site. For production sites this is always set to false.

But what do you do when you get a frantic client phone call reporting an issue on the live site? You can’t just enable WP_DEBUG for everybody and very likely break the site’s design as various error messages of sloppy plugin or WordPress’ core code might render.

Solution is simple: Enable WP_DEBUG just for you.

First, you’ll need to know your outgoing IP address. When I’m lazy I go to my friend Topher’s beautiful website which tells me my IP address.

Then edit your wp-config.php (CAREFUL) by replacing:

define(‘WP_DEBUG’, false);


if ($_SERVER[‘REMOTE_ADDR’] == ‘’) {
define(‘WP_DEBUG’, true);
} else {
define(‘WP_DEBUG’, false);

(don’t forget to replace with your outgoing IP address)

By the way this is a great solution if you’re working from home or are tethering using your phone so that you are the only one coming from this IP address. If you’re in the same building with your client and try to debug the site without freaking out the CEO this might not be the best because odds are you and her are coming from the same IP address and she’ll see the same debug junk you do.

This website is powered by WordPress, using the IndexOf theme.