This setup turns on debugging and saves errors to a log file instead of showing them on the website. You can check the file wp-content/debug.log to see what went wrong.
Wordpress
<?php
// wp-config.php snippet
// Enable debugging
define('WP_DEBUG', true);
// Enable debug log to wp-content/debug.log
define('WP_DEBUG_LOG', true);
// Hide errors from displaying on the site
define('WP_DEBUG_DISPLAY', false);
/* That's all, stop editing! Happy blogging. */
OutputSuccess
Important Notes
Always turn off WP_DEBUG on live sites to avoid showing errors to visitors.
Use WP_DEBUG_LOG to keep a record of errors without disturbing users.
Check the debug.log file regularly to catch and fix issues early.
Summary
WP_DEBUG helps you see and fix errors in WordPress.
Turn it on in wp-config.php by setting define('WP_DEBUG', true);.
Use WP_DEBUG_LOG and WP_DEBUG_DISPLAY to control where errors appear.
Practice
(1/5)
1. What is the main purpose of enabling WP_DEBUG in WordPress?
easy
A. To speed up the website loading time
B. To display and log PHP errors and warnings for debugging
C. To disable all plugins temporarily
D. To change the website theme automatically
Solution
Step 1: Understand WP_DEBUG role
WP_DEBUG is a constant in WordPress that helps developers see PHP errors and warnings.
Step 2: Identify its main use
It is used to display and log errors to help fix issues during development.
Final Answer:
To display and log PHP errors and warnings for debugging -> Option B
Quick Check:
WP_DEBUG shows errors = B [OK]
Hint: WP_DEBUG shows errors to help fix bugs [OK]
Common Mistakes:
Thinking WP_DEBUG speeds up the site
Confusing WP_DEBUG with plugin management
Assuming WP_DEBUG changes themes
2. Which line correctly enables debugging in the wp-config.php file?
easy
A. define('WP_DEBUG', false);
B. define(WP_DEBUG, true);
C. WP_DEBUG = true;
D. define('WP_DEBUG', true);
Solution
Step 1: Check correct syntax for defining constants in PHP
Constants are defined using define('NAME', value); with quotes around the name.
Step 2: Identify correct value to enable debugging
Setting WP_DEBUG to true enables debugging.
Final Answer:
define('WP_DEBUG', true); -> Option D
Quick Check:
Correct PHP constant syntax with true = C [OK]
Hint: Use define('WP_DEBUG', true); with quotes and semicolon [OK]