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 activated, 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
Another 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 your site’s front end is filled with PHP-related errors, warnings, and notices that your site visitors can see, then you can hide them by setting the WP_DEBUG mode as false. If, for some reason, 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('display_errors','Off');
ini_set('error_reporting', E_ALL );
define('WP_DEBUG', false);
define('WP_DEBUG_DISPLAY', false);
Leave a Reply