WordPress can be a great platform to design websites in a short amount of time but sometimes it can be fragile too. Has it ever happened to you where your WordPress suddenly starts to show an error message that says “There has been a critical error on this website”? Well, you may have if the website is built using WordPress. When this happens we panic and rush into many things, to help you get through this, we brought you how to fix there has been a critical error on this website.
In today’s blog, we are going to check out what causes a critical error on WordPress? how to fix there has been a critical error on this website? without further due let’s go troubleshooting.
What causes a critical error on WordPress?
“There has been a critical error on this website” is a pre-coded page that is displayed on the front of the site of a WordPress website when anything went wrong or it failed to process the request. There can be many reasons for displaying such errors, these errors can be due to themes, plugins or WordPress core file issues, or sudden time out to process. Themes are the basic skeleton of your website, there are many options such as pre-built templates to incorporate in the webpage to make a website. Similar to the case with plugins, they help in enhancing the functionality of your website.
These themes and plugins are provided by thousands of developers through the themes and plugin repository. The problem begins when there is no try-and-catch block to endure the code for fault tolerance. Secondly, since WordPress is widely written in PHP language so lots of these themes and plugin impression is dependent on the PHP version your WordPress set on. So let’s suppose you have 30 + plugins installed, if anyone is not compatible with your PHP version, the problem continues.
How to fix there has been a critical error on this website?
In this section of our blog, we are going to check what we should be doing in order to fix this issue. First things first is, we need to know where the issue is coming from, meaning, is it a theme that’s having problems, or it’s due to certain plugins? Once we know who is the culprit then it’s easy for us to fix it. Let’s check the steps out.
1) Enable the Debug mode
Debugging means a process of identifying issues towards rectifying them. Like any other CMS, WordPress also has a way to do it. This is achieved using Debug mode. When you encounter error pages in your WordPress, it’s time you should enable the debug mode. To enable the debug mode, you would need to navigate to the WordPress installation directory. If it’s cPanel, go to domain > find the domain and locate the document root for that domain. Once located, navigate to it and edit the wp-config.php file. In the wp-config.php file, look for the line that says define( ‘WP_DEBUG’, false ); and make it true simply by replacing false with true. eg : define( ‘WP_DEBUG’, true );
When you have enabled the debug mode, kindly check your website. Refresh the tab or check in the private window of the browser to see the errors. When you spot the errors, depending upon the nature of the error, we have to take action. The errors might clue it’s a plugin, multiple plugins, or a theme issue. How to deal with such an error we will check further.
Note: for cPanel users, if enabled debug mode does not show the error, navigate to cPanel admin > select PHP version > options > check the error log mark as shared above.
1.2) Deactivate plugins through the database
When we have identified that this issue is due to the plugin, we should disable them. We might wonder how to do that since the WordPress admin would also not let us in. This can be achieved by disabling the through database. You would need to go to phpmyadmin of your hosting where the database is managed. Locate the database, navigate to the wp-options table, look out for the active_plugin row, and click Edit on it. Move all active plugins and paste them into a safe notepad just in case. Click Ok below it and that’s it you have deactivated the plugins. Re-check the website to see if the error is gone. If yes, log in to WordPress admin and enable each plugin except the one in error.
Note: when you have identified the plugin, it’s your responsibility to either contact the plugin provider or find out an alternative plugin that overcomes the compatibility issue. Or undo the changes that have made it happen.
1.3) Set default theme through the database
Okay, there are times when you might see the issue isn’t due to a certain plugin, but due to the current theme that is set on the website. In order to get that fixed or reach a conclusion, we can set the website to default WordPress themes. To achieve this, navigate to the document root of your WordPress website, go to the wp-content directory, then themes, verify which default theme you already have, and note the name. Then navigate to phpmyadmin> database > wp-options table > and locate the stylesheet and template and replace it with the default theme name. Now check the website again to see if the error is gone, if not, continue further.
1.4) If nothing works, replace core files
There would be times when it comes to notice that nothing is fixing the issue. This could be due to the core files being impacted due to a script injection or bad buggy plugin code. It does break the core file flow of work and results in pretty much unfixable problems unless you know how to hardcode it. You should consider replacing the core file of your WordPress website, it’s way much easier than it sounds. We already have the article for it which you can check here. If you face any issues in replacing core files, you know where to ring the bell!
Just designing the website is not enough, there are challenges to maintaining it. When you have a WordPress website, there will be some issues that would need to be overcome from time to time. Of course, many online solutions are there to fix such issues but the more you can handle it, the better. This concludes about how to fix There has been a critical error on this website. Which step helped you in fixing your WordPress website issue? do let us know in the comments section below. If you need any help or have any suggestions to make, then do reach us via the contact page here. Happy National Nurses Day!