Recentemente, um de nossos leitores nos fez uma ótima pergunta: Como desativar os erros de PHP no WordPress?
É algo que tivemos que resolver em nossos próprios sites e sabemos como isso é importante para manter uma presença on-line confiável.
Embora os avisos e alertas do PHP ajudem os desenvolvedores a depurar problemas em seus códigos, eles parecem extremamente pouco profissionais quando ficam visíveis para todos os visitantes do seu site.
Neste artigo, mostraremos a você como desativar facilmente os erros de PHP no WordPress.

Por que e quando você deve desativar os erros de PHP no WordPress?
Os erros de PHP que você pode ver em seu site WordPress geralmente são avisos e notificações. Eles não são como erros internos do servidor, erros de sintaxe ou erros fatais, que impedem o carregamento do site.
Avisos e advertências são os tipos de erros que não impedem o WordPress de carregar seu site. Veja como o WordPress realmente funciona nos bastidores para obter mais detalhes.

A finalidade desses erros é ajudar os desenvolvedores a depurar problemas em seus códigos. Os desenvolvedores de plug-ins e temas precisam dessas informações para verificar a compatibilidade e as práticas recomendadas.
No entanto, se você não estiver desenvolvendo um tema, plugin ou site personalizado, esses erros deverão ser ocultados. Porque se eles aparecerem no front-end de seu site para todos os visitantes, isso parecerá extremamente pouco profissional.

Se você vir um erro como o acima em seu site do WordPress, informe o respectivo desenvolvedor do tema ou do plug-in. Eles podem liberar uma correção que fará com que o erro desapareça. Enquanto isso, você também pode desativar esses erros.
Vamos dar uma olhada em como desativar facilmente os erros, avisos e advertências do PHP no WordPress.
Desativação de erros de PHP no WordPress
Para essa parte, você precisará editar o arquivo wp-config.php.
Dentro de seu arquivo wp-config.php, procure a seguinte linha:
1 | define( 'WP_DEBUG' , true); |
Também é possível que essa linha já esteja definida como falsa. Nesse caso, você verá o código a seguir:
1 | define( 'WP_DEBUG' , false); |
Em ambos os casos, você precisa substituir essa linha pelo código a seguir:
1 2 3 4 | ini_set ( 'display_errors' , 'Off' ); ini_set ( 'error_reporting' , E_ALL ); define( 'WP_DEBUG' , false); define( 'WP_DEBUG_DISPLAY' , false); |
Não se esqueça de salvar suas alterações e fazer upload do arquivo wp-config.php de volta para o servidor.
Agora você pode visitar seu site para confirmar que os erros, avisos e advertências do PHP desapareceram do site.
Ativação de erros PHP no WordPress
Se estiver trabalhando em um site no servidor local ou na área de teste, talvez queira ativar o relatório de erros. Nesse caso, você precisa editar o arquivo wp-config.php e substituir o código que adicionou anteriormente pelo código a seguir:
1 2 | define( 'WP_DEBUG' , true); define( 'WP_DEBUG_DISPLAY' , true); |
Esse código permitirá que o WordPress comece a exibir novamente os erros, avisos e notificações do PHP.
Esperamos que este artigo tenha ajudado você a aprender como desativar os erros de PHP no WordPress. Talvez você também queira ver nossa lista dos erros mais comuns do WordPress e como corrigi-los, ou nossa seleção de especialistas do melhor software de web design.
Se você gostou deste artigo, inscreva-se em nosso canal do YouTube para receber tutoriais em vídeo sobre o WordPress. Você também pode nos encontrar no Twitter e no Facebook.
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