🔧 Flat-price WordPress fixes from $69 — start with a free diagnosis, no card. Get a free diagnosis →

Errors

How to Fix WordPress Errors After a PHP Upgrade

Aug 14, 2026 · 6 min read · By the Mend engineering team

If your WordPress site breaks after upgrading your PHP version, log into your hosting panel and temporarily downgrade PHP to the previous working version (such as PHP 7.4 or 8.0) to instantly bring your site back online. Once the site is accessible, enable WordPress debug logging to pinpoint the exact plugin, theme, or code snippet throwing fatal errors, then update or replace the outdated software before re-applying the PHP upgrade.

Major web hosts routinely phase out old PHP versions to enforce server security and efficiency. However, jumping from PHP 7.4 or 8.0 to PHP 8.1, 8.2, or 8.3 introduces strict language rules that frequently trigger white screens, critical error screens, or broken administrative panels on unmaintained sites.

Symptoms of PHP Upgrade Compatibility Failures

PHP compatibility issues rarely fail quietly. When your hosting server shifts to a higher PHP version without every plugin and theme being prepared, you will generally observe one or more of these symptoms:

  • The Critical Error Screen: A site-wide message stating "There has been a critical error on this website."
  • White Screen of Death (WSOD): A completely blank white page when attempting to view the site or log into /wp-admin/. See our guide on fixing the WordPress White Screen of Death for broader causes.
  • Fatal Error Warnings: Onscreen text displaying terms like Uncaught Error: Call to undefined function, Fatal error: Uncaught TypeError, or Passing null to parameter of type string is deprecated.
  • Partial Site Functionality: Broken contact forms, broken checkout flows in WooCommerce, or administrative settings pages that render as blank screens.

Why PHP 8+ Breaks Legacy WordPress Code

PHP 8.0 and subsequent releases (8.1, 8.2, and 8.3) introduced major changes to how the PHP engine executes code. Functions that were previously marked as deprecated in older versions were completely removed, and variable type enforcement became significantly stricter.

The primary causes of fatal errors during a PHP upgrade include:

  • Removed PHP Functions: Functions like create_function(), each(), and get_magic_quotes_gpc() were permanently removed in PHP 8.0. If an older plugin or custom theme file relies on them, PHP immediately halts execution with a fatal error.
  • Strict Parameter Types (PHP 8.1+): Passing null to built-in PHP functions that expect a string or array (such as strlen(), explode(), or str_replace()) now throws deprecation warnings or fatal errors instead of failing silently.
  • Undefined Array Keys & Object Properties: Accessing uninitialized variables or missing array keys throws notices and warnings that can break AJAX requests and JSON responses.
  • Abandonware Plugins: Plugins that haven't received developer updates in two or more years often contain code patterns built for PHP 5.6 or 7.2 that fail completely on PHP 8.x.

Step-by-Step Fix for WordPress PHP Upgrade Errors


Step 1: Backup Your Site and Roll Back PHP Temporarily

Before editing any files, take a full site backup if you have access to your web host's panel or backup utility. If you are locked out of the frontend and backend, your quickest route to recovery is temporarily rolling back the PHP version.

  1. Log into your hosting account dashboard (cPanel, Plesk, Cloudways, WP Engine, SiteGround, Kinsta, etc.).
  2. Navigate to the PHP Manager, PHP Version Selection, or Tools section.
  3. Select your domain name and change the PHP version back to PHP 7.4 or PHP 8.0.
  4. Save the changes and wait 60 seconds for server workers to restart.
  5. Refresh your WordPress website. In most cases, your site will load normally again, allowing you to work safely inside the dashboard.

Note: If your host has permanently retired older PHP versions and does not permit rolling back, skip directly to Step 2 to debug via FTP/cPanel File Manager.


Step 2: Enable WP_DEBUG and Debug Logging

To fix the underlying cause, you must identify which specific file and line number are breaking under the newer PHP version. Do not guess—let WordPress record the error details.

  1. Connect to your web server using an FTP client (like FileZilla) or your host’s File Manager.
  2. Open the root directory of your WordPress installation and edit the wp-config.php file.
  3. Locate the line that says define('WP_DEBUG', false); and replace it with the following code snippet:
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );

Save the file and upload it back to the server. Next, switch your hosting environment back to the newer PHP version (e.g., PHP 8.2) to trigger the error. Visit your website once to generate the error, then navigate to /wp-content/debug.log on your server.

Open debug.log and inspect the last few lines. You will see entries formatted like this:

[24-Oct-2024 14:20:10 UTC] PHP Fatal error: Uncaught Error: Call to undefined function create_function() in /home/user/public_html/wp-content/plugins/old-slider-plugin/slider.php:42

This log entry reveals the exact culprit: the file slider.php inside the plugin old-slider-plugin on line 42.


Step 3: Update, Deactivate, or Replace the Broken Plugin or Theme

Now that you know which component caused the crash, take action based on where the error originated:

  • If the error is in a third-party plugin: Log into your WordPress admin panel and update that plugin to its latest release. If no updates are available, deactivate the plugin and find a modern, active alternative. If locked out, learn how to isolate plugin conflicts manually by renaming the plugin folder inside /wp-content/plugins/ via FTP.
  • If the error is in a commercial or free theme: Check the theme author's website for an updated theme package built for PHP 8.1+. Temporarily switch to a default WordPress theme (like Twenty Twenty-Four) to verify site stability.
  • If the error is in WordPress Core: Upgrade WordPress Core to the latest stable version via Dashboard > Updates. Modern versions of WordPress Core are fully tested and compliant with PHP 8.1 and PHP 8.2.

Step 4: Fix Custom Code or Child Theme Functions

If the error log points to a file inside your child theme (e.g., wp-content/themes/my-child-theme/functions.php), the error is likely due to outdated custom code or code snippets copied from old online tutorials.

Here are two common PHP 8 fixes for child theme snippets:

Fix 1: Replacing Removed Functions

Legacy code that creates dynamic functions often uses create_function(), which is removed in PHP 8.0.

Incompatible PHP 7 Code:

add_action('widgets_init', create_function('', 'return register_widget("My_Custom_Widget");'));

Compatible PHP 8+ Code (Anonymous Function):

add_action('widgets_init', function() {
    return register_widget("My_Custom_Widget");
});

Fix 2: Handling Null Values in Built-In Functions

PHP 8.1 throws a deprecation warning or error when passing null into functions like explode() or strlen().

Incompatible PHP 7 Code:

$length = strlen( $custom_variable ); // Fails if $custom_variable is null

Compatible PHP 8+ Code:

$length = strlen( $custom_variable ?? '' ); // Provides fallback empty string

Step 5: Test in a Staging Environment and Turn Off Debugging

After applying updates or code fixes, navigate through your key pages, forms, and administrative panels to confirm full stability under the updated PHP version. For a detailed reference on update procedures, review our guide on how to update WordPress safely without breaking things.

Finally, open your wp-config.php file and disable debug logging on production by changing WP_DEBUG back to false:

define( 'WP_DEBUG', false );
define( 'WP_DEBUG_LOG', false );

How to Prevent PHP Upgrade Failures

Web hosts update default PHP versions regularly. Prevent future unexpected site outages with these maintenance habits:

  • Maintain Active Plugin Subscriptions: Avoid using unmaintained, free, or abandoned plugins that lack recent updates. Premium plugins with active licenses receive compatibility patches long before host PHP enforcement deadlines.
  • Always Test on Staging First: Most modern managed hosts offer one-click staging environments. Duplicate your live site to staging, bump the staging environment's PHP version to PHP 8.2 or 8.3, and verify functionality before touching your live site.
  • Audit Custom Snippets Regularly: Keep custom functions organized and documented. Avoid placing raw snippets directly into functions.php without verifying PHP 8+ compliance.
  • Keep WordPress Updated: Schedule routine monthly updates for core software, plugins, and themes.

When to Call a Professional Engineer

Fixing PHP compatibility errors can become complex if your site depends on custom plugins built by former developers, legacy page builders, or custom database queries. If you are unable to lower your PHP version, cannot access error logs, or find that critical custom features break under PHP 8+, it is best to involve a senior WordPress engineer.

Editing raw PHP code on a live website without adequate safeguards risks permanent database corruption or extended downtime. If you need immediate, guaranteed assistance restoring your site after a PHP upgrade, explore our specialized services:

  • If your site is currently offline due to a fatal error, order an Emergency Rescue for immediate same-day recovery.
  • If you want us to diagnose compatibility issues before upgrading your production site, submit a Free Diagnosis request.
  • For ongoing maintenance, automated backups, and version updates, view our managed WordPress Care Plan.

At Mend, our senior WordPress engineers fix broken sites fast using secure, backup-first workflows. Every fix includes a clear, plain-English report explaining what went wrong and how we resolved it.

Frequently asked questions

Can I keep my WordPress site on PHP 7.4 permanently?

Keeping your site on PHP 7.4 is dangerous because PHP 7.4 reached its official end-of-life in November 2022 and no longer receives security patches. Additionally, most major hosting providers charge security surcharges or forcibly upgrade legacy PHP versions to protect server security.

Will upgrading PHP delete my WordPress site content or database?

No, upgrading your server's PHP version alters the underlying code execution engine; it does not delete or modify your WordPress database or uploaded media files. However, code incompatibilities may prevent your site from rendering until software updates or code fixes are applied.

How do I know if my plugins support PHP 8.2 or 8.3?

Check the plugin details page in your WordPress Admin dashboard or on WordPress.org. Plugin developers specify the minimum and tested PHP versions in their release documentation. You can also test your site in a staging environment under PHP 8.2 before making the change live.