14.15. Debugging errors
TL;DR
Open
wp-config.php
and add the following code:define( 'WP_DEBUG', true ); define( 'WP_DEBUG_LOG', true ); define( 'WP_DEBUG_DISPLAY', true );
Reproduce the error you faced before.
Open
wp-config.php
and change the previously added code to the following:define( 'WP_DEBUG', false ); define( 'WP_DEBUG_LOG', false ); define( 'WP_DEBUG_DISPLAY', false );
Investigate
wp-content/debug.log
file (or the log file that is defined by your server configuration if this file does not exist) or send it to the support.
To see and log the errors in WordPress, you should enable debugging [1]. Open
wp-config.php
and add the following code above the line that says /* That's all, stop
editing! Happy publishing. */
:
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', true );
Important
If any of the lines in the code above are defined anywhere else in wp-config.php
,
please delete them.
After the code above is added, save the file. After this, your site will write errors into
wp-content/debug.log
file (or another file that is defined by your server configuration), as
well as it will display any errors in the pages of your site. To learn more about what the codes
above do, please refer to Debugging in WordPress.
Now that your site writes the errors into a log file, you should reproduce the problem you faced before so that the error is written to the log file. For example, if you see an error message when you click to a button, then make the error occur again by clicking to that button. If a page does not show its contents while it should, open that page again. If any other error occurs, make that error occur again, i.e. reproduce the error. By this way, the errors will be written to the log file. In some cases, you can see the errors in the pages as well.
After you reproduced the error, change the code you previously added to wp-config.php
to the
following:
define( 'WP_DEBUG', false );
define( 'WP_DEBUG_LOG', false );
define( 'WP_DEBUG_DISPLAY', false );
This code will disable debugging and displaying errors. Now that you got the debug file, which is
probably wp-content/debug.log
file, you can observe the file or send it to the support team so
that the errors are investigated and the problem is detected.
Important
If wp-content/debug.log
file does not exist and you do not know the location
of the debug file, you can ask your hosting provider’s support team to send the file or the
location of the file to you.
Footnotes
[1] | Debugging in WordPress |