fbpx

How to Disable WordPress PHP Error Messages

WordPress comes with a great debugging tool that developers can use when working on a WordPress website. PHP warnings help developers dictate which of the codes in the website is faulty. However, that doesn’t make the PHP error messages attractive to your website’s visitors. In this article, I will be showing you how to disable WordPress PHP error messages.

What’s the cause of the WordPress PHP Error Messages?

The PHP error messages are caused by outdated plugins or themes on your website. These plugins and themes trigger the warning due to their incompatibility with your site.

Another cause of the PHP error messages is when you pair two plugins that are conflicting when paired together. Although these plugins may work very well on their own, the issue starts when they are paired together.

While this error won’t prevent your site from working, it won’t look great to visitors coming to your site.

The PHP error messages on WordPress look like this: “/wp-content/plugins/siteplugin.php on line 30”

This error message doesn’t necessarily mean the plugin is faulty or bad. It merely shows that some part of the plugin file isn’t compatible with your current WordPress version, theme, or plugin on your site.

These error messages are used by plugins and theme developers to detect incompatibility issues and debug the issues.

However, unless you are planning to develop a theme or website, or fix the issue in the code yourself, it’s probably best if you disable the warning messages. If the tool is still working and not completely broken, then you shouldn’t really worry about the error.

How to Disable WordPress PHP Error Messages 

Before you start this, I strongly advise that you create a backup of your site before you start any coding changes. This way if anything goes wrong, you will be able to restore your site.

Disabling WordPress PHP Error Messages

Go to your website’s File Manager using the cPanel, then go to your public_html folder. In the folder, locate the wp-config.php file and click Edit.

In the wp-config file, go to the line that says:

define(‘WP_DEBUG’,true);

You can also find the line is already set to false. If set to false, you will see this code instead:

define(‘WP_DEBUG’,false);

Replace the whole line with the following code:

1| ini_set(‘display_errors’,’Off’);

2| ini_set(‘error_reporting’,

3| define(‘WP_DEBUG’,false);

4| define(‘WP_DEBUG_DISPLAY,false)

Now save the changes and go back to your website. You will find that the PHP error messages have been turned off.

Enabling PHP error messages

Sometimes you may want to keep your site’s PHP error messages on, especially when you are working or troubleshooting a website. In that case, if you want to enable the error messages again, you can go back to your wp-config.php file, follow the previous steps, and add the following code instead:

1| define(‘WP_DEBUG’,true);

2| define(‘WP_DEBUG_DISPLAY’,true);

After adding this code, save the changes. Your WordPress site will start displaying PHP error messages again.

Leave a Reply