WordPress Debug

Even an optimally maintained and carefully designed website is not immune from errors. If a variety of different plugins are installed, this can lead to problems, both small and large, that require an analysis and remedial action as quickly as possible. This is where WordPress debug mode comes in. It allows you to find errors quickly. In this article, we will explain how to use it.

What is WordPress debug?

Certain errors must be corrected as quickly as possible – from minor problems, to the dreaded WordPress white screen of death or a WordPress database error. WordPress Debug prevents you from having to check each individual plugin for these types of errors. Not only would that take a long time, but it is often unsuccessful. WordPress debug mode is a valuable tool that can help you to perform this task more effectively. Once activated, the error messages are displayed on the concerned pages, and you can then resolve the problem directly at the source.

At the same time, you can also determine which pages are running optimally and therefore do not require any corrections. WordPress debug is an important analytical tool as it shows you where the problems are as well as which parts of your website have been optimally designed and set up. All PHP errors and warnings are displayed at the top of the page, even if they do not (yet) have a lasting influence on the performance of your website.

Once the problem has been dealt with, simply deactivate the WordPress debug again. This is important as otherwise the text from your PHP code may be exposed to your visitors and thus pose a potential security risk. WordPress debug mode may also have a detrimental effect on the performance of your website.

Tip

WordPress hosting from IONOS offers many unbeatable advantages. You can choose from three pricing packages and benefit from an extensive range of safety features and round-the-clock support. At least one domain is included.

What is a WordPress debug log?

In addition to the normal debug mode, WordPress also offers a log option. If you use WordPress debug, all errors are displayed immediately, but no further documentation is created. If problems occur more often or if you want to discuss the source of the errors with an external developer, for example, accurate documentation can be very informative and ensures more effective troubleshooting in the future. Activate the WordPress debug log on your server by setting the constant ‘WP_DEBUG_LOG’ to ‘true’. WordPress will then write all error messages in the file ‘wp-content/debug.log’. This way, you can view the messages later if you wish.

Debugging WordPress manually

There are a range of different options that you can use to activate a WordPress debug. The most direct way is with the wp-config.php file. You can find this in the main directory of your website. Connect to your server via an FTP to modify the file correspondingly. To do this, proceed as follows:

  1. Always create a backup of your WordPress site to be on the safe side.
  2. Open the wp-config.php file in your Editor.
  3. Scroll down until you find the line ‘define('WP_DEBUG', false);’.
  4. Change it to ‘define('WP_DEBUG', true);’.
  5. If this line is not in the file, simply add it in yourself. The correct place to insert it is just above the comment ‘/* That’s all, stop editing! Happy blogging. */’.
  6. Save your changes by clicking at the top of the screen.

This activates the WordPress debug mode. When you have finished your analysis, simply turn off the debug mode by performing the steps above in reverse order. Reopen the file, scroll down to the line mentioned above and change the ‘true’ back to ‘false’. After saving the file, WordPress debug mode will be turned off. This procedure can be repeated as many times as you like and whenever you want to search your website for errors.

Documentation in WordPress debug mode

As mentioned above, you have the option to properly document the error analysis. You can also perform this step in the wp-config.php file. To do this, add a line under the ‘define('WP_DEBUG', true);’ line that states the following: ‘define('WP_DEBUG_LOG', true);’. Now the error messages will be saved in a LOG file and can be analysed later. With the additional line ‘define('WP_DEBUG_DISPLAY', true);’ or ‘define('WP_DEBUG_DISPLAY', false);’, which you can also use underneath, you can determine whether the WordPress debug messages should be output via HTML (true) or not (false). However, these two lines are not obligatory for WordPress debug mode.

Plugins for debugging WordPress

You can perform a debugging operation using a WordPress plugin. A very popular and free method is WP Debugging. The plugin activates after the WordPress debug mode has been installed and saves the analysis in a log file. When you deactivate the plugin, the WordPress debug stops automatically.

You can also use the Query Monitor plugin. This plugin is also free and suitable for a WordPress debug of database queries, PHP errors and other problems that you may be experiencing with tools or plugins. The plugin is relatively extensive and lists a wide variety of statistics and information.

Summary: WordPress debug is easy and useful

WordPress debug is the ideal tool for an effective error analysis of your website. It is relatively easy to activate, and you will be able to quickly understand where any problems lie, even if you are not very well-versed in the subject. If you do not want to debug WordPress manually, there are several recommended and free plugins that can carry out this task for you.

Was this article helpful?
Page top