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

  1. Log in to cPanel → File Manager
  2. Navigate to your WordPress root directory (e.g. /public_html)
  3. Open the wp-config.php file

Step 2: Enable Debug Mode

Find the following line:

 
 
 
 
 
 
PHP
 
 
define('WP_DEBUG', false);
 
 

Change it to:

 
 
 
 
 
 
PHP
 
 
define('WP_DEBUG', true);
 
 

✅ 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:

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

What These Settings Do

  • WP_DEBUG – Enables debugging
  • WP_DEBUG_LOG – Writes errors to a log file
  • WP_DEBUG_DISPLAY – Prevents errors from being shown on-screen
  • SCRIPT_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:

 
 
 
 
 
 
PHP
 
 
/* That's all, stop editing! Happy blogging. */
``
 
 

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:

  1. Enable debugging via wp-config.php
  2. Check displayed errors or review debug.log
  3. Identify the source (plugin, theme, or code)
  4. Fix or update the affected component
  5. 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.

 

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How to install the Wordpress Litespeed cache plugin

  LiteSpeed Cache – What It Is and How It Helps If you’re running a WordPress website and...

How to disable the WordPress CRON job and set it up in cPanel

  Optimising WordPress Cron (wp-cron) – Firstserv WordPress does not...

Fixing WordPress mixed content issues

  Fixing Mixed Content Warnings When you visit a website using https://, your browser expects...

How to optimise your WordPress site

Optimising Your WordPress Website (Firstserv Guide) WordPress is a...

Configuring Redis Object Caching using Litespeed Cache

Object Caching and Redis (Firstserv Guide) What is Object Caching? Object caching is a...