Debugging and Fixing WordPress Critical Errors

    September 25, 2020

    There will be times when your site will have a plugin conflict, a plugin causing an issue, or something in the active theme preventing your site from loading. If an error is detected then WordPress will send an email with the critical error to the site admin's email which will allow you to be able to login to your site and find the plugin that is causing the issue. 

    There has been a critical error on your website. Please check your site admin email inbox for instructions. 

    First, you will need to enable debugging on the site. To be able to do this you will need to have your SSH credentials for your site login using your SSH client of choice and then edit the sites wp-config.php file. 

    Set the following in your sites wp-config.php file. 

    define( 'WP_DEBUG', true ); 

    define( 'WP_DEBUG_DISPLAY', false ); 

    define( 'WP_DEBUG_LOG', true ); 

    It is possible to set the debug constants using WP-CLI commands. 

    wp config set WP_DEBUG true --raw 

    wp config set WP_DEBUG_DISPLAY false --raw 

    wp config set WP_DEBUG_LOG', true --raw 

    Now refresh your site and you should see errors being displayed by the plugin or theme which is causing the issue. 

    With debug, log enabled you will be able to access it from the wp-content folder unless you define a different path in the constant. 

    define( 'WP_DEBUG_LOG', '/tmp/wp-errors.log' ); 

    To get a list of all of your active plugins using a WP-CLI command you can run; 

    wp plugin list --status=active --format=table 

    Once you find the plugin causing the issue to deactivate that plugin using the plugin slug in the WP-CLI command. In this example, we are going to just deactivate the Classic Editor plugin. 

    wp plugin deactivate classic-editor 

    If you needed to deactivate all of the plugins then activate the plugins back in order to find the plugin conflict you can run this WP-CLI command. 

    wp plugin deactivate --all 

    If you found the issue was being caused by the theme you can activate one of the default themes which are provided. In this example, we are going to activate the Twenty Twenty theme using a WP-CLI command. 

    wp theme activate twentytwenty 

    Before changing the theme since widget areas might be replaced from the currently active theme that is being used on the site it would be recommended to back up the site database using this WP-CLI command. 

    wp db export 

    You can activate the previous theme using the wp theme activate WP-CLI command but include the theme slug out. 

    To get a list of your themes that are inactive you can run the following WP-CLI command. 

    wp theme list --status=inactive --format=table

    If you know the plugin that was recently updated and that update caused the issue then you can revert that plugin version using a WP-CLI command. 

    wp plugin install yoast-seo --activate --version=14.8.1 --force 

    Another way to update a plugin to a specific version would be by using this WP-CLI command. 

    wp plugin update yoast-seo --version=14.8.1 

    These will give you steps you need to find plugin issues, plugin conflict issues or activate theme issues. Along with how to deactivate an active theme, rollback a plugin or revert the site to a specific theme. This will allow you to be able to fix critical errors on your site. 

    Remember to set the debug constants to false when you have finished checking and fixing critical errors on your site. 

    wp config set WP_DEBUG false --raw 

    wp config set WP_DEBUG_LOG', false --raw 

    For 24-hour assistance any day of the year, contact our support team by email or through your Client Portal.

    Was this article helpful?

    Send feedback

    Can’t find what you’re looking for?

    Our award-winning customer care team is here for you.

    Contact Support