Recently, one of our readers asked us a great question: How do you turn off PHP errors in WordPress?
It’s something we’ve had to address on our own sites, and we know how important it is for maintaining a credible online presence.
While PHP warnings and notices help developers debug issues with their code, they look extremely unprofessional when they are visible to all your website visitors.
In this article, we’ll 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 custom theme, plugin, or 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 WordPress 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, or our expert picks of the best web design software.
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.
Jiří Vaněk
I’ve always disabled PHP errors the hard way with a .user.ini file uploaded to the site via FTP. But I didn’t always manage to hide the PHP errors completely, or it caused problems. I did not know that it can be done even more simply using the wp-config file. I tested it on the web and it works fine. Thanks to this, I no longer have to worry about the .user.ini file, which did not always work correctly.
Garcia
Hey, guys!
I did as you showed, but I still see warnings appearing shortly during page loading.
WPBeginner Support
It would depend on the specific error you’re seeing on your site but you can also check with your hosting provider to ensure they are not overriding what you’re setting.
Admin
A Owadud Bhuiyan
If I keep the debug true, but false the debug display. Will the error show on website?
define(‘WP_DEBUG’, true);
define(‘WP_DEBUG_DISPLAY’, false);
WPBeginner Support
The debug display being false would mean that the errors would not be visible on the front-end of your site.
Admin
Gregster
Resolved my issue instantly – waited over a week from hosting support. Thanks
WPBeginner Support
Glad our guide was able to help!
Admin
Nayanjyoti kalita
This problem is solved.
Thank You
WPBeginner Support
Glad our guide was helpful!
Admin
James Edwards
Cheers! This has saved my bacon.
WPBeginner Support
Glad our guide could help!
Admin
Janet
Thank you so much! This fixed my problem in 30 seconds that I have been waiting for my hosting to fix for over 12 hours.
WPBeginner Support
Glad our guide could help. As a reminder, this hides the error from your site but you would want to try to resolve the root cause of the error you were seeing.
Admin
shashi Bhushan shukla
Thanks a lot. This has solved my issue.
Karan
I have already done false in all . But in healthsite status always show WP debugging mode is enabled. please suggest me something
WPBeginner Support
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.
Admin
Amanda
How do I turn off warnings and notices and just leave the errors?
WPBeginner Support
We do not have a recommended method for that at the moment.
Admin
Kiran
Its not working. I am using wordpress 5.2.2
WPBeginner Support
You would want to ensure wp_debug isn’t already added in your file somewhere else.
Admin
Satinder
Thanks, it worked although i can see log file still being generated in cpanel
WPBeginner Support
You may want to check with your hosting provider to see if they have a log set up from their end
Admin
Owen Carver
That works, thank you!
WPBeginner Support
You’re welcome
Admin
Mohsin Alam
Saved me from a trouble! Thanks to WPBeginner for always helping WordPress developer.
WPBeginner Support
Glad our article could help
Admin
Rebecca P
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!
WPBeginner Support
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
Admin
David
Thanks! This page was very helpful to me.
WPBeginner Support
Glad our article was helpful
Admin
Rei
Thanks a lot for this
WPBeginner Support
You’re welcome, glad you like our content
Admin
Zeeshan
after a 1 day struggle, your solution Really helped he fix the issue
WPBeginner Support
Glad our recommendation could help
Admin
Gary Guss
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
WPBeginner Support
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.
Admin
genfoch01
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
WPBeginner Support
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.
Admin
Mzu
I need a solution on wordpress customizer that is not uploading l am stuck for weeks can’t customise any theme
WPBeginner Support
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/
Admin
Aditi
Thank you so much. You are a savior. It worked. All warnings gone.
Alfredo
Thanks a lot. This has solved my iusse.
Regards.
Abdulrahman
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