PHP warnings and notices are printing on your live WordPress pages. Set WP_DEBUG to false in wp-config.php to stop them, or pair WP_DEBUG_LOG with WP_DEBUG_DISPLAY set to false.
Why PHP warnings and notices show on live pages
Enabling WP_DEBUG causes all PHP errors, notices, and warnings to be displayed. You can turn off WP_DEBUG_DISPLAY independently to hide errors from your page HTML.
PHP's display_errors directive also determines whether errors print to the screen in output or stay hidden from users. PHP warns that display_errors is for development and should never be used on production systems connected to the internet.
Instead of displaying errors on production websites, PHP strongly advises using error logging. Pairing error logging with hidden display lets you review errors later without printing them to visitors.
Turn off debug mode in wp-config.php
Before making changes to your site, make a backup or use a staging environment first. WordPress does not recommend using WP_DEBUG or other debug tools on live sites, as they are meant for local testing and staging installs.
Open wp-config.php and find or insert the WP_DEBUG line before /* That's all, stop editing! Happy blogging. */. Set it to false to disable WP_DEBUG.
define( 'WP_DEBUG', false ); Leave false unquoted. This one is easy to miss: if you write 'false' in quotes, PHP interprets it as true because the quotes make it a string rather than a boolean.
Log errors to a file without displaying them
You can turn off WP_DEBUG_DISPLAY independently and pair it with WP_DEBUG_LOG so errors can be reviewed later. Insert these constants before /* That's all, stop editing! Happy blogging. */ in wp-config.php.
define( 'WP_DEBUG', true ); define( 'WP_DEBUG_LOG', true ); define( 'WP_DEBUG_DISPLAY', false ); @ini_set( 'display_errors', 0 ); Setting WP_DEBUG_LOG to true turns on logging, or you can set it to a valid file path to save the log elsewhere.
Watch one catch with @ini_set( 'display_errors', 0 ); in wp-config.php. PHP notes that changing display_errors at runtime with ini_set() has no effect if the script has fatal errors, because that runtime action does not execute. PHP also warns against using display_errors on production systems and advises using error logging instead.
Find which plugins need fixes before your next PHP upgrade
To check your site's PHP version, open the WordPress Dashboard, select Tools > Site Health from the sidebar menu, and open the Info tab.
WordPress recommends PHP 8.3 or higher. WordPress 6.9 added beta support for PHP 8.5, and WordPress 7.0 dropped support for PHP 7.2 and 7.3. Each PHP release branch gets two years of active support, then two more years for critical security fixes only. After four years, the branch reaches end of life and is no longer supported, so users should upgrade as soon as possible to avoid unpatched security vulnerabilities.
If your hosting company offers a staging site, update PHP there first and test your site before updating your live site.
To check installed code without turning debug output back on, I use Bright Labs Compatibility Scanner for PHP. It is a free WordPress plugin that reads every installed plugin and theme inside WordPress in short steps—needing no exec() and no shell access—and lists each file and line that uses something removed or deprecated in PHP 8.2 to 8.5 using current PHPCompatibility rules.
You can also turn on its optional update pre-scan under Tools > Bright Labs Compatibility Scanner for PHP > Settings by enabling "Check offered updates before they install", which is off by default. It checks updates WordPress offers against your server's PHP version and displays a warning on Dashboard > Updates and the Plugins screen if it finds errors, while never stopping, delaying, or changing an update.
Keep in mind that the scanner cannot promise your site will work on a newer PHP version. Because it reads code without running it, it can miss issues in code built at runtime and flag code that never runs, so treat a clean result as a good sign and test on staging first.
Checklist after you hide PHP warnings
- Reload your live pages and verify that no PHP errors, notices, or warnings appear in the page HTML.
- Confirm whether WP_DEBUG is false on your live site, or temporarily pairing WP_DEBUG_LOG with WP_DEBUG_DISPLAY set to false.
- Review your WP_DEBUG_LOG file (or the custom file path you set) later to inspect logged errors.
- Check your PHP version under Tools > Site Health > Info in the WordPress Dashboard, and test any PHP update on a staging site before updating your live site.
- Set WP_DEBUG back to false once you finish reviewing the log, since WordPress does not recommend using WP_DEBUG on live sites.
Sources
- {'text': 'WordPress Advanced Administration debugging handbook', 'url': 'https://developer.wordpress.org/advanced-administration/debug/debug-wordpress/'}
- {'text': 'PHP runtime error and logging configuration', 'url': 'https://www.php.net/manual/en/errorfunc.configuration.php'}
- {'text': 'WordPress support guide for updating PHP', 'url': 'https://wordpress.org/support/update-php/'}
- {'text': 'WordPress Core PHP version compatibility reference', 'url': 'https://make.wordpress.org/core/handbook/references/php-compatibility-and-wordpress-versions/'}
- {'text': 'PHP supported versions and end-of-life schedule', 'url': 'https://www.php.net/supported-versions.php'}
Frequently Asked Questions
I set WP_DEBUG to 'false' in wp-config.php, so why are notices still showing?
Check whether you put quotes around false. Quoted constants like 'false' are interpreted as true because the quotes make them strings rather than booleans. Write define( 'WP_DEBUG', false ); without quotes, and make sure display_errors is not enabled on your production site.
Does setting display_errors with ini_set() in wp-config.php hide fatal errors too?
No. PHP notes that changing display_errors at runtime with ini_set() has no effect if the script has fatal errors, because the runtime action does not execute. PHP warns against using display_errors on production systems and advises using error logging instead.
Does a clean scan in Bright Labs Compatibility Scanner for PHP mean my site is ready to upgrade PHP?
The scanner cannot promise that on its own. It reads code without running it, so it can miss problems in code built at runtime and flag code that never runs. Treat a clean result as a good sign, and if your host offers a staging site, update PHP there first and test your site before updating your live site.
Originally published on Bright Labs.
