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?
PHP errors that you can see on your WordPress site are usually warnings and notices. These are not like internal server error, syntax errors, or fatal errors, which stop your website from loading.
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:
define('WP_DEBUG', true);
It is also possible, that this line is already set to false. In that case, you’ll see the following code:
define('WP_DEBUG', false);
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.
If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.
I have already done false in all . But in healthsite status always show WP debugging mode is enabled. please suggest me something
You likely have it set to true in another section of the code, you likely want to reach out to your hosting provider for them to take a look and assist you.
How do I turn off warnings and notices and just leave the errors?
We do not have a recommended method for that at the moment.
Its not working. I am using wordpress 5.2.2
You would want to ensure wp_debug isn’t already added in your file somewhere else.
Thanks, it worked although i can see log file still being generated in cpanel
You may want to check with your hosting provider to see if they have a log set up from their end
That works, thank you!
You’re welcome
Saved me from a trouble! Thanks to WPBeginner for always helping WordPress developer.
Glad our article could help
I’ve been advised to turn these notices off and was directed to this article to help me with that. However, I do not have the ‘wp_debug’ line in my config file. Do I just add it in? And if so whereabouts in the file?
Thanks!
You may want to ensure you did not miss it in your current file but, you would place the code at the bottom of the file
Thanks! This page was very helpful to me.
Glad our article was helpful
Thanks a lot for this
You’re welcome, glad you like our content
after a 1 day struggle, your solution Really helped he fix the issue
Glad our recommendation could help
Clueless newbie! I’ve changed the wp-config.php file and saved it .. Do I have to upload this file to the server to get it to work? How do I do that Using Cpanel File manager.. Not seeing any debug suppression so I guess its somehow not picking up the edited file.. Halp Halp!
Thanks,
GG
If you’re using the file manager your host offers, and directly edited and saved through that without downloading the file then the changes should be active on your site and you would want to check with your host for why the changes may not be getting applied to the file.
ok so i know this is old, but i’m stumped. i am still getting php errors.
Fatal error: Uncaught Error: Call to undefined function get_header() in /path/to/wordpress/wp-content/themes/mytheme/index.php:5 Stack trace: #0 {main} thrown in /path/to/wordpress/wp-content/themes/mytheme/index.php on line 5
note that this issue was caught by a pen test and i was asked to suppress the error to avoid full paths being reveled. Any ideas would be helpful
That is a fatal error for why it is still being displayed, you would want to either change themes or let your theme’s support know about the error to let you know how to fix it.
I need a solution on wordpress customizer that is not uploading l am stuck for weeks can’t customise any theme
You may want to try disabling your plugins to see if it is a conflict due to one of those or one of the other recommendations in our troubleshooting article: https://www.wpbeginner.com/beginners-guide/beginners-guide-to-troubleshooting-wordpress-errors-step-by-step/
Thank you so much. You are a savior. It worked. All warnings gone.
Thanks a lot. This has solved my iusse.
Regards.
I faced the same problem after upating woocommerce plugin and the I used your method
all erroers disappeared, however, I cannot log into the dashboard where it wp-admin shows a blank page
is there any solution for that
Thank you