Recientemente, uno de nuestros lectores nos hizo una gran pregunta: ¿Cómo se desactivan los errores PHP en WordPress?
Es algo que hemos tenido que dirigir a nuestros propios sitios y sabemos lo importante que es para mantener una presencia en línea creíble.
Aunque las advertencias y avisos de PHP ayudan a los desarrolladores a depurar problemas con su código, resultan muy poco profesionales cuando son visibles para todos los visitantes de su sitio web.
En este artículo, le mostraremos cómo desactivar fácilmente los errores PHP en WordPress.
¿Por qué y cuándo debe desactivar los errores PHP en WordPress?
Los errores PHP que puede ver en su sitio WordPress suelen ser advertencias y avisos. No se trata de errores internos del servidor, errores de sintaxis o errores fatales, que impiden la carga de tu sitio web.
Los avisos y advertencias son el tipo de errores que no impiden que WordPress cargue su sitio web. Para más información, consulte cómo funciona WordPress entre bastidores.
El propósito de estos errores es ayudar a los desarrolladores a depurar problemas con su código. Los desarrolladores de plugins y temas necesitan esta información para comprobar la compatibilidad y las mejores prácticas.
Sin embargo, si usted no está desarrollando un tema personalizado, plugin o sitio web, entonces estos errores deben ser ocultados. Porque si aparecen en el front-end de su sitio web a todos sus visitantes, se ve muy poco profesional.
Si ve un error como el anterior en su sitio de WordPress, puede informar al desarrollador del tema o plugin correspondiente. Es posible que publiquen una corrección que haga desaparecer el error. Mientras tanto, también puedes desactivar estos errores.
Veamos cómo desactivar fácilmente los errores, avisos y advertencias de PHP en WordPress.
Cómo desactivar los errores PHP en WordPress
Para ello, deberá editar el archivo wp-config.php.
Dentro de su archivo wp-config.php, busque la siguiente línea:
define('WP_DEBUG', true);
También es posible que esta línea ya esté establecida en false. En ese caso, verá el siguiente código:
define('WP_DEBUG', false);
En cualquier caso, debe sustituir esta línea por el siguiente código:
ini_set('display_errors','Off');
ini_set('error_reporting', E_ALL );
define('WP_DEBUG', false);
define('WP_DEBUG_DISPLAY', false);
No olvide guardar los cambios y volver a subir el archivo wp-config.php al servidor.
Ahora puede visitar su sitio web para confirmar que los errores, avisos y advertencias de PHP han desaparecido de su sitio web.
Activar los errores PHP en WordPress
Si usted está trabajando en un sitio web en el servidor local o área de ensayo, entonces es posible que desee activar los informes de errores. En ese caso, es necesario editar el archivo wp-config.php y reemplazar el código que ha añadido anteriormente con el siguiente código:
define('WP_DEBUG', true);
define('WP_DEBUG_DISPLAY', true);
Este código permitirá a WordPress volver a mostrar los errores, advertencias y avisos de PHP.
Esperamos que este artículo te haya ayudado a aprender cómo desactivar los errores PHP en WordPress. Puede que también quieras ver nuestra lista de los errores más comunes de WordPress y cómo corregirlos, o nuestras selecciones de expertos del mejor software de diseño web.
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.
Syed Balkhi
Hey WPBeginner readers,
Did you know you can win exciting prizes by commenting on WPBeginner?
Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
You can get more details about the contest from here.
Start sharing your thoughts below to stand a chance to win!
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.
Administrador
Gregster
Resolved my issue instantly – waited over a week from hosting support. Thanks
WPBeginner Support
Glad our guide was able to help!
Administrador
Nayanjyoti kalita
This problem is solved.
Thank You
WPBeginner Support
Glad our guide was helpful!
Administrador
James Edwards
Cheers! This has saved my bacon.
WPBeginner Support
Glad our guide could help!
Administrador
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.
Administrador
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.
Administrador
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.
Administrador
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.
Administrador
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
Administrador
Owen Carver
That works, thank you!
WPBeginner Support
You’re welcome
Administrador
Mohsin Alam
Saved me from a trouble! Thanks to WPBeginner for always helping WordPress developer.
WPBeginner Support
Glad our article could help
Administrador
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
Administrador
David
Thanks! This page was very helpful to me.
WPBeginner Support
Glad our article was helpful
Administrador
Rei
Thanks a lot for this
WPBeginner Support
You’re welcome, glad you like our content
Administrador
Zeeshan
after a 1 day struggle, your solution Really helped he fix the issue
WPBeginner Support
Glad our recommendation could help
Administrador
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.
Administrador
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.
Administrador
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/
Administrador
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