Error Handling when building WordPress themes

When developing it’s a good idea to enable debugging, as described in this article in the developer handbook.

Essentially in wp-config.php you want to define the WP_DEBUG as true.

define( 'WP_DEBUG', true );

This will cause WordPress to output more errors and warnings to the screen, which can help finding issues. You can also log these to wp-content/debug.log by setting WP_DEBUG_LOG to true:

define( 'WP_DEBUG_LOG', true );

In 5.2+ you might also want to disable the ‘fatal error handler’, which is responsible for the screen that’s displaying the “the site is experiencing technical difficulties” message.


Just keep in mind that none of these should be turned on in a live environment.