How to enable or disable PHP error reporting for WordPress

Enabling PHP warnings and error notices for WordPress

WordPress PHP error reporting, warnings and notices should be disabled by default. If for some reason you want to enable them for example, you need to debug your newly installed theme or plugin, then there are a few ways to achieve this.

Using a Plugin

The most user-friendly way is using a plugin like Easy Error Reporting. Once installed and activate you can set which user type will be able to see the error logging so you won’t scare away your regular visitors.

Editing wp-config.php

One more way is by directly editing the wp-config.php file of your WordPress installation. In there you should add the following lines:

// Enable WP_DEBUG mode
define( 'WP_DEBUG', true );

// Enable Debug logging to the /wp-content/debug.log file
define( ‘WP_DEBUG_LOG’, true );

// Disable display of errors and warnings
define( ‘WP_DEBUG_DISPLAY’, false );
@ini_set( ‘display_errors’, 0 );

This setup lets you log all errors, notices and warnings in a file under the name debug.log which will be saved under the wp-content directory.

How to disable WordPress PHP warnings and error notices

If for some reason your site frontend is filled with PHP related errors, warnings and notices which can be seen from your site visitors then you can hide them by setting the WP_DEBUG mode as false. If for some reasons this doesn’t work, for example, you’re using a cheaply shared hosting account, then replace that line of code inside your wp-config.php file with this one:

ini_set('error_reporting', E_ALL );
define('WP_DEBUG', false);
define('WP_DEBUG_DISPLAY', false);

You may also like

Leave a Reply

Your email address will not be published. Required fields are marked *