How to Fix 'A Critical Error Occurred on Your Website' After PHP8 Update on WordPress
"A Critical Error Occurred on Your Website" Error and Solution After PHP8 Update on WordPress Site
For WordPress-based websites, php 7.4 and older versions may no longer be sufficient. Up-to-date, fast and working better with new integrations, php 8.0 and later updates are of great importance. Although php 8.0 and later provide much better results for WordPress, unfortunately, they currently have major incompatibility problems with themes and plugins.
I am encountering the error “A critical error has occurred on your website” after updating to PHP 8 and above
First of all, you need to determine what is causing the error. If you encounter the "A Critical Error Occurred on Your Website" screen and error when you open your WordPress site, an email from the system will be automatically sent to the admin email address.
First, check the inbox of the valid admin email address on your website.
The incoming email will be as follows;
Hello!
There is a feature in the WordPress admin section that detects when a plugin or theme
is causing a serious problem on your site and notifies you with this automatic email .
In this case, WordPress found an issue with your theme, Woodmart.
First, go to your site (https://www.kaeducator.com/) and
see if there are any visible issues. Then, open
the page where the error is located (https://www.kaeducator.com/wp-admin/post.php?post=7038&action=edit)
and see if there are any visible issues.
Please contact your service provider to help investigate this matter further .
If your site appears to be broken and you can’t access the admin area normally
, there is now a special WordPress “recovery mode” that lets
you securely log into your admin dashboard
to conduct further investigations.
https://www.xxx.com/wp-login.php?action=enter_recovery_mode&rm_token=wxxxxxxxxxxxxx&rm_key=n5s0wWHBlDjiupIn5dpJS6
To keep your site safe, this link
will expire in 1 day. Don't worry about it though.
If the problem occurs again after it expires, a new link will be emailed to you.
When looking for help with this issue, you may be asked for some of the following information:
WordPress xxxxx version
Theme used: xxxx
Plugin used: (version )
PHP version 8.0.30
Error details
=================== An error of type E_ERROR occurred in
/home/xxxx/public_html/wp-content/themes/xxxxx/inc/integrations/visual-composer/maps/brands.php
on line 81. Error message:
Uncaught ValueError: Unknown format specifier “S” in
/home/xxxxx/public_html/wp-content/themes/xxxxxx/inc/integrations/visual-composer/maps/brands.php:81
Stack trace:
#0 /home/xxxxxx/public_html/wp-content/themes/xxxxxx/inc/integrations/visual-composer/maps/brands.php(81):
sprintf('Al\xC4\xB1nan brands…', '
The source of the error is clear at the bottom of the incoming e-mail. It is stated that it originates from brands.php, line 81. In other words, the problem experienced here is a theme-related problem.
If you see the name of a plugin installed on your website, the error is caused by that plugin. If you see a file name or folder path belonging to your theme, the problem is caused by your theme.
Other topics that may interest you:
- How to Move Any Windows to Another Drive (Easiest Method)
- How to Choose an Advertising Agency for Digital Success: A Complete Guide
- How to Choose a Safe Bitcoin Wallet?
The E-mail Showing Me the Error Was Not Delivered (In Case of No SMTP Setting and No Mail Receiving)
Find the following line in the opened file;
define('WP_DEBUG', false);
Change false its expression here to and save the file.true
In the email that shows the source of the error, you can now view the factor that triggered the critical error on your website. After making this update, trigger the error again, which will display the message A Critical Error Has Occurred on Your Website .
It will show you the source of the error in detail and the error lines will start to appear in writing at the top of the admin panel. If you cannot view the error, open the error_log file in cPanel. The reason that triggered the error will appear here.
How to Fix Plugin-Related “A Critical Error Occurred on Your Website” Problem?
After performing the above steps, identify the plugin that is causing the error. Then, find the folder of the relevant plugin in the public_html/wp-content/plugins folder and update its name by adding “1” to the end.Once the folder name where the plugin is installed is updated, it will be disabled and your website will continue to work without errors.
The plugin that is causing the error is probably having compatibility issues with php 8.
How to Fix Theme-Related "A Critical Error Occurred on Your Website" Problem?
First, take a full backup of your website . Remove all plugins belonging to the theme from your website. Then download the installation files of your theme again and re-upload them. Then make sure that WordPress, the theme and all plugins are up to date.
If this still does not solve the problem, the theme you are using may not be compatible with PHP 8. The best solution is to contact the theme developer and explain the situation.
Don't Forget to Disable Debug Mode After Resolving the Issue!
After fixing the issue that triggered the critical error, in the wp-config file;
define('WP_DEBUG', true);
Change true its expression here to and save the file.false
In the admin panel, PHP error lines appear at the top of my site for visitors to see. How can I turn this off?
If PHP error lines are visible at the top of the admin panel, or even if these error lines are visible at the top of the site – from the visitors’ perspective – when you visit your site in incognito mode define('WP_DEBUG', false);, do not worry if the error lines are still visible despite what you have done.
define('WP_DEBUG', false); Again, copy the following lines instead of the expression in the wp-config file ;
ini_set('display_errors','Off');
ini_set('error_reporting', E_ALL );
define('WP_DEBUG', false);
define('WP_DEBUG_DISPLAY', false);
Afterwards, save the file. Now PHP error lines will not be displayed both in the admin panel and for visitors.