WordPress Debugging Tools: How to Use Them Correctly


Table of Contents:



WordPress is a powerful and flexible content management system, but it may occasionally require debugging and error diagnostics. Built-in debugging tools help developers and website administrators detect errors, optimize performance, and resolve potential plugin or theme conflicts. So, how should you properly use the debug mode, and what should you watch out for?

Key Debugging Constants in WordPress

WordPress offers several built-in constants that enable the activation of debugging mode and provide more detailed information on errors and warnings. These constants are set in the wp-config.php file in the root folder of WordPress. To activate it, you will need FTP access to your website to edit the wp-config.php configuration file, where you can add the constants.

1. WP_DEBUG

This constant is the main switch for activating the debugging mode in WordPress.

				
					define('WP_DEBUG', true);
				
			

If the value is set to true, WordPress will display PHP errors and other warnings directly on the page. When set to false, this mode is turned off.

2. WP_DEBUG_LOG

This constant allows errors to be logged into the debug.log file, which is located in the wp-content folder (or it will be created when the constant below is enabled).

				
					define('WP_DEBUG_LOG', true);
				
			

This is especially useful when you want to track errors without them being visible to website visitors, while still having a complete record of these errors in a text file.

3. WP_DEBUG_DISPLAY

It determines whether errors are displayed directly on the page or not. If set to false, errors will not be shown in the browser but will still be logged (if WP_DEBUG_LOG is active).

				
					define('WP_DEBUG_DISPLAY', false);
				
			

It is recommended to combine this with WP_DEBUG_LOG to track errors without disturbing website users.

4. SCRIPT_DEBUG

This constant forces the loading of unminified versions of CSS and JavaScript files, making it easier to debug styles and scripts.

				
					define('SCRIPT_DEBUG', true);
				
			

It is mainly used during the development and customization of themes or plugins.

5. SAVEQUERIES

If this constant is set to true, WordPress will log all executed SQL queries and their execution times.

				
					define('SAVEQUERIES', true);
				
			

Stored queries can then be analyzed using the variable $wpdb->queries, which helps identify slow queries that may be slowing down the website.

How to use debug mode safely?

Jak zabezpečit WordPress - FAQ

1. Don’t Use Debugging on a Production Website

Leaving WP_DEBUG active on a live website can lead to sensitive error messages being displayed to visitors. This could reveal server information or even allow hackers to exploit certain vulnerabilities.

2. Use WP_DEBUG_LOG Instead of Displaying Errors

If you need to track errors on a live site, it is recommended to enable only WP_DEBUG_LOG and set WP_DEBUG_DISPLAY to false.

3. Disable Debugging After Completing Tests

Once you’ve finished debugging, make sure to set all debug constants back to false or remove them from the wp-config.php file.

Practical Example of Using Debug Mode

Let’s imagine that after activating a new plugin, your WordPress site started showing the White Screen of Death. What can you do?

1. Open the wp-config.php file and add the following lines:

				
					define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);
				
			

2. Save the file and reload the website. The white screen will remain, but errors will be logged in the wp-content/debug.log file.

3. Open debug.log and find the last error that caused the issue.

4. Deactivate the problematic plugin via FTP or through the database.

5. After resolving the issue, turn off debug mode.

Conclusion

WordPress debugging tools are very useful for identifying issues and optimizing website performance. However, if misused on a live site, they can expose sensitive information or disrupt the user experience. Therefore, it is important to use them carefully and only when necessary. By following best practices, these tools can greatly assist in managing and developing a WordPress website.

The website is created with care for the included information. I strive to provide high-quality and useful content that helps or inspires others. If you are satisfied with my work and would like to support me, you can do so through simple options.

Byl pro Vás tento článek užitečný?

Klikni na počet hvězd pro hlasování.

Průměrné hodnocení. 0 / 5. Počet hlasování: 0

Zatím nehodnoceno! Buďte první

Jak užitečný vidíte tento článek.

Sledujte mě na sociálních médiích.

Je mi líto, že pro Vás nebyl článek užitečný.

Jak mohu vylepšit článek?

Řekněte mi, jak jej mohu zlepšit.

newsletter

Subscribe to the Newsletter

Stay informed! Join our newsletter subscription and be the first to receive the latest information directly to your email inbox. Follow updates, exclusive events, and inspiring content, all delivered straight to your email.

Are you interested in the WordPress content management system? Then you’ll definitely be interested in its security as well. Below, you’ll find a complete WordPress security guide available for free.

Odebírat
Upozornit na
guest
0 Komentáře/ů
Nejstarší
Nejnovější Nejvíce hlasováno
Vložené zpětné vazby.
Zobrazit všechny komentáře.

Pokud mi chcete napsat rychlou zprávu, využije, prosím, níže uvedený
kontaktní formulář. Děkuji.

Další Kontaktní údaje