Errors 3 min read

How to Turn Off PHP Errors in WordPress

PHP warnings and notices on a live site look unprofessional and can expose server details. Here's how to hide them safely in WordPress while still logging errors so you can fix them.

On this page

Key takeaways

  • PHP warnings and notices shown on a live site look unprofessional and can expose server paths to attackers.
  • Turn display off in wp-config.php with WP_DEBUG set to false, or keep logging on with display off.
  • Hiding errors isn’t fixing them — check the log and update the plugin or theme causing them.

Messages like “Warning: Undefined array key… in /home/user/public_html/wp-content/plugins/…” appearing at the top of your pages usually mean debug display was left on, or the host shows errors by default. Here’s how to hide them properly — and still see them when you need to.

Option 1: the standard wp-config.php settings#

Open wp-config.php (in your site’s root folder) and find any existing WP_DEBUG line. Replace it with:

define( 'WP_DEBUG', false );

Make sure this is above the line /* That's all, stop editing! */.

define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );

Visitors see nothing, while errors are written to wp-content/debug.log. You can also set a custom log path outside the web root for security:

define( 'WP_DEBUG_LOG', '/home/user/logs/wp-errors.log' );

Option 3: hosting control panel#

Many hosts (cPanel’s “MultiPHP INI Editor”, hPanel’s PHP configuration) let you set display_errors = Off. If errors still show after changing wp-config.php, the host setting or a plugin may be overriding it.

Errors still showing?#

  • Search wp-config.php for a second WP_DEBUG definition further down.
  • Check for ini_set( 'display_errors', 1 ) in plugins or functions.php.
  • Check .htaccess or .user.ini for php_flag display_errors on.
  • Clear page and CDN caches — cached pages may still contain old error text.

Need a hand with this?

Get a quick, honest review of your website’s SEO.

Chat on WhatsApp

Understanding error types#

Type Meaning Action
Notice / Deprecated Code uses outdated or sloppy patterns Update the plugin/theme; usually harmless
Warning Something unexpected, but code continues Investigate; may cause wrong output
Fatal error Code stopped — page breaks Fix immediately — see white screen of death

Fix the cause#

  1. Open debug.log and note which plugin or theme file is mentioned.
  2. Update that plugin/theme — many warnings come from PHP 8 changes fixed in newer versions.
  3. If it’s abandoned, look for an alternative.
  4. Delete old log files periodically; they can grow large.

PHP errors FAQ#

Do PHP warnings affect SEO?#

Visible warnings can break layouts, appear in search snippets and look unprofessional. Fatal errors can make pages unavailable. Hide display and fix the cause.

Is it safe to leave WP_DEBUG_LOG on?#

Yes, if display is off and the log isn’t publicly accessible. Store it outside the web root or block access to it.

Why did errors appear after a PHP upgrade?#

PHP 8 is stricter. Outdated plugins trigger warnings or deprecations; update them.

Found this useful? Share it

Join the discussion

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

Security code image. If you cannot read it, press refresh or contact me on WhatsApp.