How to Disable PHP Errors in WordPress

One of our readers recently inquired about how to disable PHP errors in WordPress. PHP warnings and alerts assist developers in troubleshooting their code. However, when they are accessible to all of your website visitors, it appears highly unprofessional. In this article, we will demonstrate how to simply disable PHP errors in WordPress.

Why and When Should You Disable PHP Errors in WordPress?

PHP errors on your WordPress site are typically warnings and alerts. This is not the same as an internal server error, syntax problems, or fatal errors, which prevent your website from loading.

Notices and cautions are problems that do not prevent WordPress from loading your website. For additional information, see how WordPress works behind the scenes.

These errors are intended to assist developers in debugging difficulties with their code. This information is required by plugin and theme developers in order to check for compatibility and best practices.

If you are not creating a theme, plugin, or custom website, these errors should be hidden. Because they look incredibly unprofessional if they appear on the front-end of your website to all of your visitors.

If you notice an error similar to the one described above on your site, you should contact the theme or plugin provider. They may provide a fix that eliminates the error. Meanwhile, you can disable these errors.

Let’s see how to simply disable PHP errors, notifications, and warnings in WordPress.

Disabling PHP Errors in WordPress

You will need to make changes to the wp-config.php file for this step.

Look for the following code in your wp-config.php file:

define('WP_DEBUG', true);

It’s also conceivable that this line has been set to false already. In that instance, the following code will be displayed:

define('WP_DEBUG', false);

In either instance, you must substitute the following code for this line:

ini_set('error_reporting', E_ALL );
define('WP_DEBUG', false);
define('WP_DEBUG_DISPLAY', false);

Remember to save your modifications and re-upload your wp-config.php file to the server.

You can now browse your website to confirm that the PHP problems, alerts, and warnings have vanished.

Activating PHP Errors in WordPress

If you are working on a website on a local server or staging area, you should enable error reporting. In that scenario, modify your wp-config.php file and replace the code you previously added with the following:

define('WP_DEBUG', true);
define('WP_DEBUG_DISPLAY', true);

With this code, WordPress will be able to display PHP errors, warnings, and alerts once more.

We hope this article was useful in teaching you how to disable PHP errors in WordPress.

Leave a Reply