Instantly hide PHP Warnings & Notices in WordPress

WordPress is one of the most used CMS in the world. You can use it for blgs, stores, forums or even intranet CMRs – it’s open source and very flexibile.

However, there are times when, because of a theme or plugin code, you will see some PHP notices or warnings on your websiteThose are not errors, are simple warnings and notices, and pretty sure you want to hide them until you get some time to fix them, but how to do that?

WordPress

NOTE: even if the notices and the warnings are not doing any harm to your website, you should take them in consideration and find some time to fix them. If you don’t know how to do it, just check the notice and see if it’s related to a specific plugin or theme and contact the developer letting them know the PHP version you are using and the notices or/and the warnings you see on your website.

Most of the time, these are nothing to worry about (though the plugin/theme developer should know about these so that they may fix them in a future release).

Some of these can even be generated because the developer has to keep compatibility with older versions of WordPress as well as older PHP versions.

Please keep in mind that you can hide these notices, warnings but on the long terms, this is not actually something I recommend. The best would be to make sure those are not generated at all. Even those are just warning or notices, it’s strongly recommended to take action right away and do the necessary changes to your code or to your web hosting environment and get rid of them. You can use this trick, just to make sure the visitors experience is smooth and they will not see those scary warnings and notices, but in the end, you must update your code and fix them.

Hide PHP Notices and warnings in WordPress:

If you simply set WP_DEBUG to false in your wp-config.php file you should be fine. These don’t affect your site in any way.

However, the problem is that some times the above does not work due to some enforced server settings.

In that case, here is a work around that pretty sure will do the trick. Go ahead and replace this line from your wp-config.php file:

define('WP_DEBUG', false);

with the following ones:

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

once you save the changes, clear your installation cache and browser cache and try again. If you still have that issue, let me know with a comment bellow and we will try to help you out!

Reply