Hello again. Today I’m gonna show how you can hide the PHP Warnings and Notices from your WordPress site. Normally disabling debug display does the trick. But what if you see the Warnings and Notices even after disabling the debug display?

What is Debug and Debug Display in WordPress

If you are a developer, you already know what debugging is. If you don’t know, debugging is identifying and fixing errors from any application. In WordPress, you can enable debugging with “WP_DEBUG” constant.

But, what is “WP_DEBUG”? And how is that managed in WordPress?

Debugging PHP code is part of any project, but WordPress comes with specific debug systems designed to simplify the process as well as standardize code across the core, plugins and themes. WP_DEBUG is a PHP constant (a permanent global variable) that can be used to trigger the “debug” mode throughout WordPress. It is assumed to be false by default and is usually set to true in the wp-config.php file on development copies of WordPress.

Source: WordPress Official Codex

So, with the WP_DEBUG constant, you can control if debugging will be enabled on your site or not.

Still not sure how you can enable/disable debug in WordPRess? Simply login to your server with any FTP Application like FileZilla or Transmit. Or if you have cPanel on your hosting, open the File Manager. Then go to the root directory of your site. Files will look like this:

From there, open the “wp-config.php” file and find this line:

define('WP_DEBUG', false);

This line should be inside the “wp-config.php” as default. It means, debug is disabled. To enable this, simply change the “false” to “true“. And that’s it. It will enable the debug mode in WordPress.

There are actually 3 debug constants for debugging in WordPress:

  • WP_DEBUG
  • WP_DEBUG_LOG
  • WP_DEBUG_DISPLAY

In the same way as “WP_DEBUG” is defined, you can also define the other two constants:

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

There are Two more related constants:

  • SCRIPT_DEBUG
  • SAVEQUERIES

But these are not the main point of this article, so I’m skipping them for now.

Debug Display Disabled, Still Showing Warnings and Notices

Yes, this is the problem we will be dealing with in this article. When Debug Display is disabled, WordPress should not display any kind of PHP Warnings or Notices, but a few hosts sometimes force displaying PHP Warnings and Notices. This can be configured from the PHP Configuration file from your server. But in many cases, you might not have access to your “php.ini” file. So what to do?

Very simple, in your “wp-config.php” file, find this line:

define('WP_DEBUG', false);

And simply replace that with the following lines:

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

That’s it, bam!

So what do these lines do actually? The first two lines override the Error Display and Error Reporting settings from your PHP Configuration file. The third line disables WordPress Debug, and the fourth line disables WordPress native Debug Display.

You can know more about editing the “wp-config.php” file in details from here: WordPress Official Codex for WP Config Editing

It’s very simple and easy, right? This could cause a headache if you didn’t know exactly what to do. But now as you know this trick, it might save you some time for a beer or a coffee!

Please let me know in the comments section if you didn’t understand any part of this article, or if you still have any confusion. I’ll try to help you in fixing your problem.

Cheers!

Posted by Rupok Chowdhury

Tech Support Ninja at WPMU DEV. WordPress enthusiast, Apple fanboy, Game of Thrones Fan, Photographer, Musician and fun-time Blogger.