WordPress users encounter many errors that result from some modifications to the plugin files or templates installed on the site. Fortunately, almost all errors are solvable in WordPress. As it is a completely organized content management system, it has a lot of tools and methods through which it is possible to resolve programming errors and restart the site with complete efficiency.
One of these errors that you may have encountered is the fatal error . This error causes your site to stop working, and displays a message informing you that there is a fatal error on the site, as shown in the following image:
In this article, we will learn about the fatal error that occurs on WordPress sites, the possible reasons for this error to occur, and how it affects the site. We will also learn about many solutions through which this error can be overcome and resolved on the WordPress website, without the need to possess many complex programming skills.
Before we begin the explanation, we always advise you to take a backup copy of the site before making any modifications to the code or source files of your site, to avoid any possible data loss during the modification process.
What is the fatal error?
The Fatal Error is one of the most famous and frightening errors in WordPress, which WordPress site owners are terrified to see, because this fatal error causes the entire site to stop working and a white screen to appear with a message telling the visitor that there is a fatal error on the site. You will also face a problem accessing your WordPress site’s control panel (Wp-admin) if there is a fatal error in it.
In fact, the critical error message varies in form and accompanying text, depending on the way the site programmer or developer wrote and formatted the code that controls the appearance of software errors on the site.
When a fatal error appears on your site, you should not panic at all, because although the fatal error is one of the errors that WordPress website owners do not want to see, it is easy and simple to deal with. There are many methods that you will learn about in the article that will help you solve and overcome this error easily and return the site to its normal state again.
Reasons why the fatal error appears in WordPress
The appearance of the fatal error in WordPress is due to some errors in the source codes for templates or plugins installed on the site. In the following lines, we list for you the most important reasons that lead to the appearance of the fatal error on your site:
- The fatal error may appear when updating WordPress, and in this case the cause is one of the previous plugins installed on the site that is not compatible with the modern version of WordPress.
- Not paying attention to updating website templates and plugins when they are available may cause the fatal error to appear.
- Modifying the source code in the Htaccess file . Or the wp-config.php file or other WordPress source files incorrectly, or without having sufficient experience and skill to modify those files.
- Missing or modifying the Functions.php file incorrectly may cause the fatal error to appear on the site.
- Sometimes a fatal error occurs as soon as a WordPress plugin is installed, and in this case the reason is that the plugin is not compatible with the codes of some other plugins on the site.
- Failure to automatically update WordPress may cause a fatal error to appear. This may be the result of the site server’s connection to WordPress being interrupted during the update. In this case, the best treatment for the error is to manually update WordPress .
- Another common cause of a fatal error may be the site’s low memory size, and this problem often occurs on shared or poorly resourced hosting.
How to find out why a fatal error occurred on your WordPress site
After we learned about the possible reasons for the fatal error to appear on a WordPress site, the question on your mind now must be, “How do I determine the sure reason for the fatal error to appear on my site?”
When a fatal error occurs on your WordPress site, you will often see the message in this succinct form:
But as you can see in the previous image, there is no explanation or reason for the error in the previous message.
Therefore, we will first take a very important step to make WordPress show us the cause of the fatal error instead of just displaying a message titled “There was a fatal error on your site,” which does not give us any useful information about why the error occurred!
Go to the site’s file manager > then go to the WordPress installation folder < and open the Wp-config.php file in edit mode by right-clicking on it and then choosing the Edit command to modify some of the codes inside it:
After opening the edit page for the code file, look for the following code:
As the following picture shows you:
All you have to do now is change the word false to true in order to activate the debugging mode. Then save the file by clicking the Save Changes button as shown in the following image:
Now that you have made this simple change to the wp-config.php file, the fatal error will appear on your WordPress site in a completely different way, as it will appear in text form telling you the reason that led to the fatal error appearing on the site.
See the following image, which shows what the fatal error looks like on the site after making a programmatic modification to the config.php file
As you can see in the previous image, the critical error on the site has become displayed in a more detailed and useful way, as the reason behind the error appears. For example, the reason the fatal error appears here is because there is an undefined function inside the header.php folder of the current WordPress theme.
Warning : Although activating error correction mode is a useful and quick way to uncover the causes of a fatal error. But it is not preferable to activate it on live sites, because the error message will then appear to all visitors to the site, and it may reveal details about your code, your site paths, and other information that you may not want to display.
Therefore, some developers resort to displaying debugging information in a file called /wp-content/debug.log and canceling it on the site pages so that it does not appear in front of visitors, by also adding the following code to the Wp-config.php file after the previous code:
In all cases, you must return the code to its previous default state and cancel debug mode by returning the value of the WP_DEBUG programming constant to false after being able to handle the error and return the site to its normal state.
Types of Fatal Error and how to fix it yourself
After we learned in the previous paragraphs about the fatal error and how it affects the WordPress site, we also learned about most of the possible reasons for the fatal error to appear on your WordPress site.
Now we move to the most important part, in which we list the types of fatal errors that may occur on your WordPress site, the best way to deal with each type of them, and how to fix them to return the site to its normal state again.
Fatal error resulting from an undefined function call
The previous image shows the alert form for this error (Call to undefined function) , which is one of the most serious errors that occur in WordPress. But on the other hand, it is considered the easiest mistake to fix.
When your site encounters this fatal error, read the error message (remember that the error message will not appear like this if you do not activate the Debug option to the value True in the wp – config file as we explained in the previous paragraphs of the article).
You will notice that the error message shows you the name of the software file that contains the code causing this error. In this case, as shown in the error message, the problem is located in the header.php file, specifically in line number 2 of the file.
Now we will access the header.php file inside the WordPress file manager on the hosting, and we will find that line 2 actually contains a function named mynewfun exactly as it appears in the error message:
All you have to do now is delete this essentially undefined function. Therefore, your site will function properly.
Note : We created the previous error to illustrate the example, nothing more. We wrote the name of a function and called it while it was not defined in the file, so that the error appears and we explain the idea to you.
This error may appear for other reasons, including a problem with one of the add-ons installed on the site. In this case, the solution is in the next paragraph, in which we will explain the error resulting from site additions.
Fatal error resulting when installing or updating an add-on
One of the most common reasons why a fatal error appears on your site is the installation of a plugin that is not compatible with the current version of WordPress on your site.
The issue also appears when you update one of the plugins, and you immediately notice the fatal error message appearing on your site after the update.
The following image shows what the error message resulting from one of the plugins installed on your site looks like:
As you notice, the name of the add-on appears in the error message, so the solution lies in entering the site’s file manager and deleting the folder for the add-on.
Go to the plugins folder from within the site’s file manager, then go to the WordPress installation folder, then the wp-content folder , then the plugins folder
After entering the folder, you can access the add-on folder – which is often named with the same name as the add-on – and delete the folder or change its name, and you will notice that the error disappears immediately from your site.
Note : If the cause of the error is one of the add-ons on the site, the best solution in this case is to delete the add-on completely or uninstall it, and write to the add-on developer with this problem to solve it. We do not advise you to modify the add-on’s source codes because that may cause bigger problems if not. Your complete knowledge of all the programming functions and features that were relied upon in building this add-on.
Fatal error resulting from installing or updating a template
One of the common cases where the fatal error appears is when you are installing a WordPress theme or updating an already installed theme.
In this case, the reason is clear to you as the error appears immediately after installing the template, so the quickest solution here is to uninstall the template from within the WordPress file manager.
Go to the site’s file manager > open the WordPress installation folder > then go to the wp-content folder > inside it you will find the Themes folder that contains the template files installed on the site. Enter this folder as shown in the following image:
After you enter the templates folder, you can delete the template folder that caused the error, or change the name of the folder so that WordPress returns to its previous state before the error occurred.
Note: In this case, when the WordPress template is causing this error, you must make sure that you are using the latest version of WordPress before installing the template. Otherwise, you can write to the template developer about the problem to solve it on his part.
For this reason, we always advise you to take a backup copy of your site before you install plugins or change the theme of your WordPress site.
htaccess file fatal error.
Sometimes on WordPress sites that are managed by more than one person, the source code files, such as the htaccess file, are accessed. And modify it, then a fatal error may occur due to incorrect modification of this file.
In this case, the solution is to restore the .htaccess file. To its default mode before applying any changes to it, to do this you can go to its hosting file manager > then go to the WordPress installation folder > and you will find the .htaccess file inside it. Delete this file from the file manager as shown in the following image (you can download it to your device first to save a copy of it).
After deleting the file, it can be generated again and returned to its default mode, by going to the WordPress control panel, then going to Settings > Permanent Links, then clicking on the “ Save Changes ” button without changing anything because this step will generate the .htaccess file again automatically. :
Fatal error due to storage space exceeded
The previous image shows the error resulting from exceeding the memory space on the WordPress site (Allowed Memory size exhausted) . This error results from the presence of many programming commands running within the site at the same time, and these programming commands need memory space in order to function and be executed properly. .
This space is often set to 64 MB by default in most WordPress sites that are hosted on servers with limited resources, which subsequently causes a fatal error to appear due to running out of space.
The solution to this error is very simple. You can access the wp-config.php file inside the WordPress installation folder in the site’s file manager on the hosting, and then paste the following code into it:
This code increases the PHP memory limit needed to run code within WordPress. This is done by setting the value of the variable WP_MEMORY-LIMIT to 512 MB. You can increase it more than that, provided that the hosting company allows you to increase this space, because there are some companies that do not allow the value to increase beyond a certain number. Therefore, you will then be bound by the maximum amount of memory allowed by the hosting company.
After pasting the code into the wp-config.php file like this, save the file and you will notice the fatal error disappears:
Learn more details about the Memory exhausted error in WordPress.
Fatal error due to code execution time exceeded
This error message appears when the site takes a lot of time to execute a programming command or implement certain changes within the site, and when it exceeds the maximum time allowed to implement those changes, then this error message will appear to inform you that the site has exceeded the maximum time allowed to implement those changes.
In this case, the easiest solution is to increase the maximum time the code is allowed to take to implement changes to your site.
To do this procedure, go to the WordPress file manager, then to the WordPress installation folder within the hosting, and search inside it for the settings file called php . ini and open it in edit mode.
If you do not find this file, create it yourself by clicking on +File as shown in the following image and writing the new file name php . ini
Then open this file and paste the following code into it:
Here we set the value of the software variable max_execution_time to 600 seconds, which is equivalent to (5 minutes).
This variable is used to set the maximum time allowed for the site to execute code and apply various changes to it, and its default value is usually 30 seconds.
After applying the changes, save the file, and you will notice that the maximum execution time problem disappears:
It is also worth noting here that you can alternatively resolve this error in other ways such as making modifications to the .htaccess file code. in WordPress and add the following code to it:
Or by making modifications to the code of the wp-config.php file in WordPress and adding the following code to it:
Of course, do not forget to take a backup copy of any file before you modify it.
Note : You can increase the value to more than 600 seconds if the maximum time spent issue persists.
The fatal error is caused by the component editor
Another case where your site might encounter a critical error is when you install the advanced Gutenburg plugin editor on a very old version of WordPress.
In this case, you have two options, the first is to update WordPress to a new version. Or just use the traditional WordPress editor, because the advanced editor basically doesn’t work well with very old versions of WordPress.
Conclusion
Now that you know the different reasons and possibilities for a fatal error to appear on your WordPress site and ways to fix and get rid of it, it should no longer be so scary. Although this fatal error causes the site to crash, a white page to appear in front of visitors, and prevents you from logging in to the control panel, it can be dealt with and eliminated in many available ways.
You can also protect your site from being exposed to fatal errors by adhering to the security procedures within the site, the most important of which is periodically updating WordPress, as well as constantly updating templates and plugins, and not installing any unreliable plugin within your site.
Also, make sure before you install any plugin or template on your site that it is compatible with your current version of WordPress to avoid this type of error occurring in it
Leave a Reply