The problem:

I want to run Wordpress 6.x with PHP 8.x in development mode - meaning define('WP_DEBUG', true); but Wordpress 6.x partial support for PHP 8.x throws a lot of deprecated warnings which do a lot of mess on the screen and also mess with cookies and REST API.

Setting error_reporting(E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED); in php.ini or wp-config.php does not solve the problem because Wordpress overwrites this setting when you set define('WP_DEBUG', true); which you want normally have for the development.

The solution is no straight forward and I couldn't find fast, either on Stack or anywhere else so below I will answer my own question and solve the problem for others.

  • error logging should be done to a file rather than printing to the screen, but keep in mind that support for 8.0 is incomplete, I'd advise avoiding 8.0 for now if these are a concern, especially when using plugins and purchased themes
    – Tom J Nowell
    Jun 7 at 9:32
  • For development personally I like to see errors on the screen. Regarding the 8.0 readiness - yeah that is my concern - normally I use only narrow set of plugins (which are frequently updated) so at the moment I'll try and see what happens. The thing is that PHP is recently really quick with deprecating it's PHP versions 7.4 is supported only till the end of 2022 so there's really not much time and given the lifetime of an average template I thing one should really try the 8.x as soon as possible.
    – Picard
    Jun 7 at 10:23

1 Answer 1


The key to the solution is enable_wp_debug_mode_checks filter but to use it you have to do something special.

As the documentation says:

This filter runs before it can be used by plugins. It is designed for non-web runtimes. Returning false causes the WP_DEBUG and related constants to not be checked and the default PHP values for errors will be used unless you take care to update them yourself.

To use this filter you must define a $wp_filter global before WordPress loads, usually in wp-config.php.

Then when you disable this default error reporting overwrite - you can set your own. So the final solution looks like this:

define('WP_DEBUG', true);

if (WP_DEBUG) {
  define('WP_DEBUG_LOG', true);
  define('WP_DEBUG_DISPLAY', true);

  // disable friendly non informative error messages

  $GLOBALS['wp_filter'] = [
    'enable_wp_debug_mode_checks' => [
      10 => [[
        'accepted_args' => 0,
        'function'      => function() { return false; },

error_reporting(E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED);

Unfortunately it turns off automatically also deprecated messages from your own code, but what can you do until Wordpress solves its deprecated code fragments.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.