critical error

How to Fix: “There Has Been a Critical Error on This Website” in WordPress

If you manage a WordPress site, encountering a “There Has Been a Critical Error on This Website” message can be quite distressing. And it doesn’t matter if you’re using your site for simple blogging or running a full-fledged e-commerce store — WordPress errors can still invoke a general sense of panic.

This critical error, usually triggered by issues in PHP, plugin conflicts, or theme functions, stops your website from operating correctly. And if your site isn’t working correctly, that means a potentially ruined SEO ranking, missing out on prospects, and losing sales.

Let’s explore a detailed approach to resolving this error, ensuring your site’s smooth and efficient functionality.

What is the Critical Error in WordPress?

This error message is WordPress’s way of indicating a significant problem that prevents the PHP code from executing properly, leading to the site’s unavailability.

critical error
What the critical error looks like in WordPress.

Typically, it involves issues with the latest changes made to the site, such as updates to plugins, themes, or core WordPress files. Understanding the root cause is essential for effective troubleshooting.

Common Plugin and Theme Conflicts on WordPress Websites

Conflicts between WordPress plugins or themes and the WordPress core can lead to various types of errors, including the dreaded “fatal error” or the “white screen of death.” These issues typically stem from compatibility problems, especially after updates that introduce new code that doesn’t play well with existing plugins or themes.

Here are a few reasons why this issue might occur:

  1. Version Incompatibility: One of the most common causes of conflicts is the incompatibility between the versions of WordPress, plugins, and themes. When WordPress core updates to a new version, plugins and themes may not be immediately compatible if they haven’t been updated to work with the new version. This mismatch can lead to parts of your website not functioning correctly or failing to load at all.
  2. Resource Conflicts: Plugins and themes might conflict over the resources they try to use. For example, two plugins could attempt to modify the same WordPress hook or filter in ways that are incompatible with each other. Such conflicts can lead to unexpected behavior or prevent one or both plugins from functioning correctly.
  3. JavaScript Conflicts: Many plugins and themes include their own JavaScript, and conflicts can arise if multiple extensions are trying to execute JavaScript on the same page. This can lead to functionality breaking down, especially if one script errors out, potentially affecting all subsequent scripts.
  4. CSS Overlaps: Similar to JavaScript conflicts, CSS conflicts occur when multiple themes or plugins try to style the same elements differently. This can result in visual anomalies on a website, where the intended design does not display correctly due to overlapping or conflicting CSS rules.
  5. Database Query Overload: Some plugins or themes may use inefficient database queries or make excessive requests to the database. This can slow down the website or, in worse cases, lead to a server error due to the overwhelming number of queries being executed.
  6. PHP Errors: Plugins and themes that contain poor coding or are incompatible with the current version of PHP running on your server can lead to PHP errors. These errors often result in the “fatal error” or “white screen of death,” where the site crashes entirely or fails to load a critical component.
  7. Admin Conflicts: In the WordPress admin panel, conflicts can arise when multiple plugins attempt to modify the same settings or administrative interfaces. This can lead to issues such as inaccessible settings, broken layout in the dashboard, or even security vulnerabilities if the conflict exposes or breaks functionality intended to protect the site.

Each of these potential causes requires a different approach to troubleshooting and resolving the conflict, often involving deactivating plugins or themes to isolate the issue, checking error logs, or updating to the latest versions of the involved extensions.

Detailed Troubleshooting Steps

If you get the WordPress critical error, there are a few things you can do to set things right. Follow this procedure to get your site back on track:

1. Activate Recovery Mode

When a critical error message occurs, WordPress tries to send an admin email with a link to enter recovery mode. Recovery mode allows you to safely manage your site’s backend without affecting its online visibility. This is crucial for performing diagnostics and resolving the issue without interrupting user experience.

recovery mode
Recovery Mode

2. Deactivate All Plugins

Plugins often cause compatibility issues, especially after updates. To test this, start by deactivating all plugins through the WordPress admin panel. If this resolves the issue, reactivate them one by one to identify the culprit.

If you don’t have access to your admin panel, access your site via an FTP client or your hosting provider’s file manager. Navigate to the wp-content/plugins folder and rename it, effectively deactivating all plugins. If this resolves the issue, reactivate each plugin one by one to isolate the problem​.

3. Switch to a Default Theme

Themes can also be the source of critical errors. To check if this is the cause of the issue, switch your active theme to a default WordPress theme like Twenty Twenty from the wp-content folder.

To access this, you’ll need to go to wp-content/themes folder in your host’s file manager where your theme files are stored.

You can do this by renaming your current theme’s directory. This method helps determine if the error is theme-related. If switching to the default theme resolves the error, the problem lies within your original theme​.

4. Activate Debug Mode

Enabling WordPress debug mode is a valuable tool in identifying the specific line of code causing a critical error. Add the following lines to your wp-config.php file to enable debugging:

define('WP_DEBUG', true);

define('WP_DEBUG_LOG', true);

define('WP_DEBUG_DISPLAY', false);

This setup logs errors to a debug.log file within the wp-content directory without showing them to visitors of your site.

5. Increase PHP Memory Limit

A low PHP memory limit might be causing the error, especially under heavy site load. Increase the memory limit by adding the line define('WP_MEMORY_LIMIT', '256M'); to your wp-config.php file. This increases the memory allocation for your site, potentially resolving the error. Check with your hosting provider if you encounter restrictions on memory adjustments​.

6. Check and Enable PHP Error Logs

Understanding the specific error causing the site’s failure is easier if you enable debugging and check PHP error logs. Edit your wp-config.php file to include the following code:

define('WP_DEBUG', true);

and

define('WP_DEBUG_LOG', true);

This will log all errors to a debug.log file within the wp-content directory, providing insights into what might be going wrong​.

7. Update PHP Version

Sometimes, the PHP version can cause compatibility issues. Ensure your web hosting supports the latest version of PHP recommended by WordPress, and upgrade if necessary. A dedicated WordPress hosting plan might be necessary to ensure your site runs on the correct PHP version.

8. Clear Cache

Sometimes, a corrupted cache can lead to critical errors. Clearing your site’s cache using your caching plugin or through your hosting dashboard can resolve transient issues that appear as critical errors​.

9. Restore Your Site From a Backup

UpdraftPlus
UpdraftPlus

If troubleshooting doesn’t resolve the issue, consider restoring your site from a backup. This can quickly revert any recent changes that might have introduced the error. Use tools like UpdraftPlus or your hosting provider’s backup solutions to restore your site to a previous state where the error did not exist​.

10. Update or Reinstall WordPress

An outdated or corrupted WordPress installation can lead to critical errors. Consider updating to the latest version of WordPress or reinstalling the core files. This can be done via the WordPress dashboard or by manually uploading the latest WordPress files via FTP​.

Advanced Debugging Techniques

Advanced debugging techniques go beyond the basic settings wp-admin, offering deeper insights into the WordPress core and the server environment.

  • Using WP-CLI: WP-CLI provides another way to manage WordPress settings. It includes debugging. Commands like wp plugin deactivate --all can deactivate all plugins, simplifying the process of testing for conflicts without using the admin panel.
  • Interpreting Error Logs: Access your web server’s error logs through cPanel to get detailed reports on what’s going wrong. These logs can provide specifics about PHP errors, server errors, and more, which are crucial for diagnosing problems related to the WordPress core or php scripts.
  • Local Development Environment: Setting up a local version of your WordPress site can allow you to test changes without affecting the live site. Tools like XAMPP or Local provide an easy way to mimic your live site’s environment, where you can experiment with different configurations and code snippets without fear of breaking your live site.
Local
Local
  • Query Monitoring: Plugins like Query Monitor can detect and report on slow database queries, scripts, HTTP API calls, and user capability checks, providing a comprehensive overview of your website’s performance and pinpointing issues that could lead to critical errors.

These advanced techniques require a more technical approach but offer the precision necessary for complex WordPress environments and significant customisations. When you take advantage of these tools, you can maintain greater control over the site’s backend and preemptively tackle issues that might otherwise lead to critical errors.

Preventive Measures and Maintenance Tips

There are some things you can do to prevent such critical errors from happening in the future, too. Here’s a brief look at what you should prioritise:

  • Regular Updates: Keep WordPress, themes, and plugins updated to ensure compatibility and security.
  • Use Staging Environments: Test updates and changes in a staging environment before applying them to your live site.
  • Security Practices: Implement strong security measures to protect your site from malware and attacks.
  • Regular Backups: Maintain regular backups so you can quickly restore your site in case of failure.

Address Critical Errors and Keep Your Site Performing Well

Troubleshooting a critical error on your WordPress site can be complex, but by methodically following these steps, you can pinpoint the issue and restore your site’s functionality.

Always consider seeking professional assistance if the problem persists, as some issues may require expert intervention. For further guidance, visit detailed tutorials available on WordPress.org or consult with your hosting provider for specialised support.

And if you need someone to handle site maintenance for you, we’d love to be of assistance, our WordPress site maintenance plans ensure your site is in good hands, 24/7.