Disable PHP Error Messages in WordPress

How to Disable WordPress PHP Error Messages

WordPress has a built-in method of debugging that works great for developers. It offers a warning message detailing what file is at fault and what line to look at. However, the PHP error messages often look terrible from a visitor’s perspective in WordPress.

Luckily, we can change this

In this tutorial, I’m going to show you how to disable the warning message in WordPress when it comes to debugging. It’s a simple bit of code you can copy and paste into your website.

If you need more help working out your WordPress Errors, our support crew is waiting to help you resolve any issues. If you are not yet hosting with one of the Fastest WordPress Hosts around, then maybe you should consider it…. and yes we also offer free migration of your site from your old host to us.

What Causes these PHP Error Messages?

A lot of the time, line warnings in PHP files happen because of outdated plugins or themes. This is because core files will often change with WordPress updates, which makes some parts of code obsolete.

Themes and plugins can also throw PHP warning messages when used with something that is incompatible. It’s possible for two current plugins which work well by themselves to have issues when paired together. This is because every developer is different, and not everyone uses the same syntax when developing website files.

Luckily, these warnings don’t necessarily mean the site is broken. They just look ugly to an unsuspecting visitor. Sometimes the developer will create an update to fix the warning, but it’s not always quick.

PHP warnings in WordPress look something like this:
/wp-content/plugins/siteplugin.php on line 30

This doesn’t mean the plugin is bad. It just means part of the file is incompatible with WordPress, the theme, or another plugin that is in use.

Unless you plan on fixing the coding yourself, it’s probably better to simply disable the warning messages altogether. If the tool isn’t completely broken or unusable, then the warning may not completely apply to you.

Disable the PHP Error Messages In WordPress

Step 1: Access the File Manager

This next part involves editing the wp-config.php file of WordPress to disable PHP warnings.

I strongly suggest you create a backup of your site before making any coding changes. This will protect you in the event something goes wrong by giving you a quick method to restore the site.

You have several methods available for accessing the wp-config.php file of WordPress. A lot of people like using FTP applications like FileZilla to access website resources.

For this tutorial, I’m simply going to use the File Manager in cPanel.

Use File Manager to fix the PHP error messages in WordPress

Step 2: Locate and Enter the wp-config File

Access your website by clicking the “public_html” folder in the directory.

PUBLIC HTML

Select the wp-config.php file and click, “Edit.” It’s located in the top toolbar of File Manager.

Edit

Click the “Edit” button on the new window. This is just a message allowing you to change the character encoding of the editor. You will not need to make any changes to this section.

Click Edit

Step 3: Edit the wp-config File

By default, WordPress will show visitors PHP error messages, we can change this by replacing a single line of code. Scroll down and find the line that has this code:

define('WP_DEBUG', false);
Find PHP Code

You may see “true” instead of false. Either way, you’re looking for the “WP_DEBUG” portion of the wp-config.php file.

Replace the 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);
Replace Code to remove the PHP error messages in WordPress

Click the “Save Changes” button in the top right.

Save Changes

Once the file is saved, this will disable the PHP warnings in WordPress.

Re-enabling PHP Error Messages In WordPress

Sometimes, it is very helpful to show PHP errors in WordPress, especially when troubleshooting an issue. Thus, if you want to enable PHP errors again, edit the lines you added in the previous step by pasting this instead:

define('WP_DEBUG', true);
define('WP_DEBUG_DISPLAY', true);
You can enable the PHP error messages in WordPress with this code

Customizing Your Website

Hiding WordPress warnings are only one piece of a massive customization puzzle within WordPress. With a simple copy-and-paste code, you can make a variety of changes without having previous experience in website development.

Just make sure you’re copying good snippets of code. Something that is obsolete or improperly created could easily crash a website.

How often do you edit coding in your WordPress site? Where is your favorite place to go for code snippets?

20 thoughts on “How to Disable WordPress PHP Error Messages”

  1. What if this one doesn’t work? How long does it take for the changes to take effect? It is not resolving my issue. I hope you could help me further.

    1. Michael Phillips

      Hi Bob. We’re in the process of reviewing all of the tutorials to make sure they work with WordPress 5.x. If we find a problem with this one it will be updated and we’ll verify that it’s working.

  2. You may want to format how you’re showing this code. It didn’t work for me until I saw another comment that said to replace the quotation marks. I had the same issue when I copied it because it looked like it was using some styled quotation marks and after retyping them they look like default ones.

  3. The problem is that these code examples are not properly formated to show clean code. It contains quotation mark instead of ‘ or ” Everyone copy+paste this codes run into errors because of this.

  4. Replace ‘ with ‘ and this will work.

    I suggest the author update the article with formatted code, so newbies can copy-paste and make it work for them. Thanks for the article – Good one.

    Thanks

  5. Gaga, thank you for pointing out the difference in the ‘ if you just copy and paste the code. That fixed my issues. Thank you a million times!

  6. copy paste it from here with the correct quotes and will work

    /* define(‘WP_DEBUG’, false);*/
    ini_set(‘display_errors’,’Off’);
    ini_set(‘error_reporting’, E_ALL );
    define(‘WP_DEBUG’, false);
    define(‘WP_DEBUG_DISPLAY’, false);

  7. ini_set(‘display_errors’,’Off’);
    ini_set(‘error_reporting’, E_ALL );
    define(‘WP_DEBUG’, false);
    define(‘WP_DEBUG_DISPLAY’, false);

  8. I’m amazed this isn’t fixed. The quotes are wrong and will throw endless exceptions in your error log as well as make certain features of your site not work!

    The code given by Kaumil Patel is wrong. @Vernam has given the correction.

  9. It seems the codes are deprecated. The below codes works perfectly
    error_reporting(0);
    @ini_set( ‘display_errors’, 0 );
    define(‘WP_DEBUG’, false);
    define( ‘WP_DEBUG_DISPLAY’, false );

    Cheers all

  10. If you copy and paste from this page, just delete and replace all the quotes in the code, and it’ll work just fine!
    Thank you.

  11. I was facing the same issue of the error of php error on WordPress. Thanks for helping me in the same. Subscribed your blog.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.