Here’s our complete, structured guide to debug and fix WordPress issues effectively, from basic errors to advanced troubleshooting. We’ve broken it down into sections so you can follow step by step.


1. Enable Debugging in WordPress

WordPress has a built-in debugging system controlled via wp-config.php. Always start here.

  1. Open wp-config.php in the root directory of your WordPress site.
  2. Add or update these lines:
// Enable WP debug
define('WP_DEBUG', true);

// Log errors to wp-content/debug.log
define('WP_DEBUG_LOG', true);

// Display errors on site (useful for dev, not production)
define('WP_DEBUG_DISPLAY', false);

// Script & CSS debugging
define('SCRIPT_DEBUG', true);
  • WP_DEBUG – Turns on WordPress debugging.
  • WP_DEBUG_LOG – Saves errors to wp-content/debug.log.
  • WP_DEBUG_DISPLAY – Hides errors from front-end (better for live sites).
  • SCRIPT_DEBUG – Forces WordPress to use unminified CSS & JS.

Tip: After enabling, check wp-content/debug.log for error messages.


2. Check PHP Errors

  • Make sure your hosting allows PHP error logging.
  • Add in wp-config.php if needed:
ini_set('display_errors', 0);
ini_set('log_errors', 1);
ini_set('error_log', ABSPATH . 'wp-content/php-errors.log');
  • You can view PHP errors in wp-content/php-errors.log.

3. Common WordPress Issues & Fixes

a) White Screen of Death (WSOD)

Cause: PHP fatal error, memory limit, plugin/theme conflict.

Fix:

  1. Increase PHP memory limit in wp-config.php:
define('WP_MEMORY_LIMIT', '256M');
  1. Deactivate all plugins (rename wp-content/plugins folder temporarily).
  2. Switch to a default theme (twentytwentyone or similar).
  3. Reactivate plugins one by one to find the culprit.

b) 500 Internal Server Error

Cause: Corrupt .htaccess, plugin, theme, or PHP error.

Fix:

  1. Backup your .htaccess file and regenerate:
# Rename .htaccess
mv .htaccess .htaccess_backup
  1. Go to WordPress Admin → Settings → Permalinks → Save Changes (this generates a new .htaccess file).
  2. Check plugins and theme conflicts as in WSOD.

c) Database Connection Errors

Cause: Wrong DB credentials or corrupt DB.

Fix:

  1. Check wp-config.php:
define('DB_NAME', 'your_db_name');
define('DB_USER', 'your_db_user');
define('DB_PASSWORD', 'your_db_password');
define('DB_HOST', 'localhost'); // or host from your provider
  1. Repair DB by adding:
define('WP_ALLOW_REPAIR', true);

Then visit https://your-site.com/wp-admin/maint/repair.php.


d) Slow Site / Performance Issues

Fix:

  • Enable caching (plugins like W3 Total Cache or WP Rocket).
  • Optimize images (use Smush or Imagify).
  • Use a CDN (Cloudflare, BunnyCDN, KeyCDN).
  • Remove unused plugins and themes.
  • Minify CSS/JS (via plugins or SCRIPT_DEBUG toggle).

e) Theme & Plugin Conflicts

  1. Deactivate all plugins and switch to default theme.
  2. Activate one plugin at a time and check the site.
  3. Use browser console (F12) to check JS errors.

  • Go to Settings → Permalinks → Save Changes to refresh rewrite rules.
  • Check .htaccess for correct WordPress rewrite rules:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

4. Advanced Debugging Tools

a) Query Monitor

  • Plugin that shows DB queries, hooks, HTTP requests, PHP errors, and more.

b) Debug Bar

  • Adds a debug menu in admin bar with error messages and warnings.

b) Health Check & Troubleshooting

  • Plugin by WordPress.org.
  • Provides environment info and safe-mode testing (disable plugins/themes temporarily without affecting visitors).

5. Debugging JavaScript & CSS

  • Open Browser DevTools (F12):

    • Console tab → check JS errors.
    • Network tab → check failed requests.
  • Check theme scripts for jQuery dependency conflicts.
  • Ensure no mixed HTTP/HTTPS content.

6. Error Logging & Notifications

  • Use error_log() in PHP to debug functions:
error_log('Debug: variable value = ' . print_r($variable, true));
  • This goes to wp-content/debug.log.

7. Safety & Backup Tips

  • Always backup your site before major changes.
  • Use staging environments for debugging before production.
  • Keep WordPress, themes, and plugins updated.

8. Quick Debug Checklist

Issue Quick Fix
White Screen Increase memory, deactivate plugins/themes
500 Internal Server Error Check .htaccess, plugin/theme conflicts
Database Error Check DB credentials, repair DB
Broken Permalinks Re-save permalinks
Slow Site Caching, CDN, optimize assets
JS Errors Browser console, plugin/theme conflict
Plugin/Theme Conflict Safe mode, activate one by one

✅ Pro Tip:

For professional debugging, always log errors instead of showing them to users, and use plugins like Query Monitor and Health Check to pinpoint issues quickly.


Struggling with Persistent WordPress Errors?

Sometimes, debugging a complex WordPress site requires a deep dive into the core files and database. If you’re facing recurring issues or need a professional security audit, NeedleCode is here to help. Our services include:

  • Emergency WordPress Repair: Fast fixes for the White Screen of Death and 500 errors.
  • Security Hardening: Protecting your site from malware and unauthorized access.
  • Performance Tuning: Resolving slow loading times and database bloat.

Don’t let technical debt slow you down. Contact NeedleCode Today for expert WordPress troubleshooting and maintenance services.