Recently one of our readers asked how to turn off PHP errors in WordPress? PHP warnings and notices help developers debug issues with their code. However it looks extremely unprofessional when they are visible to all your website visitors. In this article, we will show you how to easily turn off PHP errors in WordPress.
Why and When You Should Turn Off PHP Errors in WordPress?
Notices and warnings are the kind of errors that do not stop WordPress from loading your website. See how WordPress actually works behind the scenes for more details.
The purpose of these errors are to help developers debug issues with their code. Plugin and theme developers need this information to check for compatibility and best practices.
However, if you are not developing a theme, plugin, or a custom website, then these errors should be hidden. Because if they appear on the front-end of your website to all your visitors, it looks extremely unprofessional.
If you see an error like above on on your site, then you may want to inform the respective theme or plugin developer. They may release a fix that would make the error go away. Meanwhile, you can also turn these errors off.
Let’s take a look at how to easily turn off PHP errors, notices, and warnings in WordPress.
Turning off PHP Errors in WordPress
For this part, you will need to edit the wp-config.php file.
Inside your wp-config.php file, look for the following line:
It is also possible, that this line is already set to false. In that case, you’ll see the following code:
In either case, you need to replace this line with the following code:
ini_set('display_errors','Off'); ini_set('error_reporting', E_ALL ); define('WP_DEBUG', false); define('WP_DEBUG_DISPLAY', false);
Don’t forget to save your changes and upload your wp-config.php file back to the server.
You can now visit your website to confirm that the PHP errors, notices, and warnings have disappeared from your website.
Turning on PHP Errors in WordPress
If you are working on a website on local server or staging area, then you may want to turn on error reporting. In that case you need to edit your wp-config.php file and replace the code you added earlier with the following code:
define('WP_DEBUG', true); define('WP_DEBUG_DISPLAY', true);
This code will allow WordPress to start displaying PHP errors, warnings, and notices again.
We hope this article helped you learn how to turn off php errors in WordPress. You may also want to see our list of the most common WordPress errors and how to fix them.