Enable WordPress Debugging For Efficient Plugin Development

Enable WP_DEBUG and start seeing PHP notices and also WordPress-generated debug messages. This is helpful when building plugins. WP_DEBUG tells PHP to report more errors, specifically “notices,” since WordPress normally instructs PHP to only report warnings and fatal errors. It also will help you to know if you’re using a deprecated function, deprecated file, or an old API.

Simply open wp-config.php and define:

1
define( 'WP_DEBUG', true );

You can also define WP_DEBUG_DISPLAY and WP_DEBUG_LOG to suppress the notices and log them to a wp-content/debug.log file if you’re debugging on a production site:

1
2
3
4
define( 'WP_DEBUG', true ); 
define( 'WP_DEBUG_LOG', true ); 
define( 'WP_DEBUG_DISPLAY', false ); 
ini_set( 'display_errors', 0 );

Comments (3)

  1. Thanks a lot, Sarah!

    I was aware of ‘WP_DEBUG’ but I didn’t know that it’s also possible to log those errors, specially supressing their output on display.
    Nice tip, thanks again :)

  2. Thank you very mutch for this article. After reading a while the very helpful articles on this page I really regret the decision to have my blog on blogger since I can´t apply the mentioned methods. But if I get another blog I´ll definetly try WP!

    Greetings.

Participate