WordPress: get a debug information without showing it to blog visitors

Sometimes there is an error in your WordPress installation that you can’t spot by checking all the settings or disabling plugins one by one which supposedly are causing it.

Then the only way to get a list of errors is by switching WP_DEBUG from a default “false” to “true”.

You can change it in wp-config.php located in the main root of your WordPress installation. That’s fine if you’re working on a new blog, but definitely not recommended if you want to do it in the working blog, the one already visible to blog visitors.

The reason is that the list of errors will be displayed at the top of the page, so turning the debug on, even for a short while, just to copy the information, isn’t the best idea.

Instead, you can get a list of errors by downloading a debug file. Your visitors won’t see a code mess when they discover your blog, but you’ll get a chance to check out the debug list any time you want.

Here’s what to do.

How to get a debug information as a file

1. In the wp-config.php find:

define('WP_DEBUG',false);

and replace it with:

define('WP_DEBUG',true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);
@ini_set('display_errors',0);

2. From now on, when you type the URL http://yourblog.com/wp-content/debug.log (where yourblog.com is the domain of your WordPress installation), the debug file will get immediately downloaded to your computer.

After you find and fix the issue, consider replacing the code back to define('WP_DEBUG_LOG', false);, as the debug file stores the entire data since you turned the debug on, so it gets longer and longer.

You should be able to open it with any text editor.

I’m trying to figure out what’s the reason a newly published post gets shared on Facebook as “Page not found”.

This might have something to do with Joast SEO, as in the debug information there is:

PHP Notice:  get_wpseo_options is deprecated since version WPSEO 1.5.0! Use WPSEO_Options::get_all() instead. in /wp-includes/functions.php on line 2908
PHP Notice:  wpseo_get_value is deprecated since version WPSEO 1.5.0! Use WPSEO_Meta::get_value() instead. in /wp-includes/functions.php on line 2908
PHP Notice:  wpseo_get_value is deprecated since version WPSEO 1.5.0! Use WPSEO_Meta::get_value() instead. in /wp-includes/functions.php on line 2908

More on WordPress:

[pi-archive number=5 tag=”WordPress”]

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: