Debugging PHP Errors in WordPress (Firstserv Guide)
WordPress is built using PHP, so from time to time you may encounter PHP-related errors. A common example is the “white screen of death”, where your website displays a completely blank page.
To identify and fix these issues, you can use WordPress’s built-in debugging tools along with server error logs.
Where to Look for Errors
When troubleshooting, useful information can often be found in:
- PHP error logs (via cPanel or your hosting environment)
- error_log files within your website directory
- WordPress debugging output using WP_DEBUG
Enable WordPress Debug Mode
WordPress includes a built-in debugging feature that can display errors directly on your site or log them to a file.
Step 1: Edit wp-config.php
- Log in to cPanel → File Manager
- Navigate to your WordPress root directory (e.g.
/public_html) - Open the
wp-config.phpfile
Step 2: Enable Debug Mode
Find the following line:
Change it to:
✅ This will display PHP errors directly on your website.
Important
- Only enable this temporarily while troubleshooting
- Do not leave debug mode enabled on a live site, as it may expose sensitive information
- Once finished, set it back to
false
Logging Errors to a File (Recommended)
Instead of displaying errors publicly, you can log them to a file for safer debugging.
Add or update the following lines in wp-config.php:
What These Settings Do
WP_DEBUG– Enables debuggingWP_DEBUG_LOG– Writes errors to a log fileWP_DEBUG_DISPLAY– Prevents errors from being shown on-screenSCRIPT_DEBUG– Forces WordPress to use unminified scripts for deeper debugging
Where to Find the Log File
Errors will be stored in:
/wp-content/debug.log
You can open this file via cPanel File Manager or download it for review.
If WP_DEBUG Is Missing
If the WP_DEBUG line does not exist in your wp-config.php, you can add it manually.
Place it above this line:
Common Causes of PHP Errors
Debugging output often points to:
- Outdated or incompatible plugins
- Theme issues
- PHP version conflicts
- Custom code errors
✅ The error message and file path usually indicate where the issue originates.
Best Practices
- Enable debugging only when needed
- Always back up your site before making changes
- Disable debugging once the issue is resolved
- Keep WordPress, themes, and plugins fully updated
Summary
To troubleshoot WordPress PHP errors:
- Enable debugging via
wp-config.php - Check displayed errors or review
debug.log - Identify the source (plugin, theme, or code)
- Fix or update the affected component
- Disable debugging once resolved
If you need help diagnosing a WordPress error or interpreting your debug logs, the Firstserv support team is always available to assist.
