Hide PHP Errors From Showing On Website

In rare cases, a Plugin or Theme will cause “errors” on the front-end of websites. Some hosts such as WP Engine technically “hide” errors from being displayed in the actual browser, but the errors themselves may still be happening. Other hosts, such as ServerPilot do not prevent these errors from displaying.

So in addition to the errors being “logged” into an error log file, they may also display at the top of your website’s content. Obviously not ideal on a production site.

If you have errors showing that aren’t causing actual PROBLEMS, then it should be OK to hide them for the time being. However please reach out to the plugin developer with the error lines, so they can know about fixing it. Most of the errors are related to a new “array” warning that wasn’t a big deal in PHP 5.6, but is now technically wrong in PHP 7. Though, the warning rarely actually breaks anything.

To Remove the Errors from the Front-end

Please take a look at this: aristath.github.io/blog/wp-hide-php-errors

The bottom chunk of code is what you’d need. Here it is:

ini_set('error_reporting', E_ALL );
define('WP_DEBUG', false);
define('WP_DEBUG_DISPLAY', false);
  1. FTP into your server.
  2. Find your app’s wp-config.php file.
  3. Open that file and add those lines of code before the
    /* That’s all, stop editing! Happy blogging. */ line
  4. For example: https://d.pr/free/i/glwovT
  5. Save the file and overwrite the old one for your app
  6. The errors should now be suppressed, to no longer display

PHP error wp-config example

See our featured website design work

Check out some of the beautiful websites we’ve built for over 2,000 clients.

We offer WordPress support & maintenance

Shake the stress of ongoing maintenance with plans supported by our team of WordPress experts.

Related articles