How to update PHP on WordPress safely

A step-by-step way to update PHP on WordPress without breaking your site, covering backups, staging, compatibility checks, the switch itself and quick rollback.

To update PHP on WordPress safely, back up the site, update WordPress, your theme and plugins first, test the new PHP version on a staging copy, then switch the live site in your hosting control panel and check the key pages straight away. If anything breaks, you switch back to the previous version in the same panel, which takes a minute. Done in that order, a PHP update is one of the least risky maintenance jobs there is.

PHP is the programming language WordPress runs on. Your host decides which versions are available, and you choose which one your site uses. Newer versions are faster and get security fixes. Old ones stop receiving security patches, which leaves the site exposed even if WordPress itself is up to date.

Most sites I am asked to fix after a PHP update broke for one of two reasons: an outdated plugin or theme that was never updated, or the update was done on the live site with no backup. Both are avoidable.

Why the PHP version matters

Each PHP release has a support period. After active support ends, it gets security fixes only for a while, and after that, nothing. Running an unsupported version means newly found security problems in PHP itself will not be patched.

There are practical reasons too:

  • Newer PHP versions are generally faster, which helps uncached pages, the admin and WooCommerce checkouts.
  • Plugin and theme developers drop support for old PHP versions over time, so you eventually cannot install updates.
  • WordPress shows a warning in Site Health when your PHP version is old.

The WordPress requirements page lists the recommended PHP version, and php.net publishes the support dates for each release. Check both before choosing the version to move to. As a rule, I move clients to the newest version that their host offers and their plugins support, rather than one step at a time.

Step 1: Find your current version

In the WordPress admin, go to Tools > Site Health > Info and open the Server section. It shows the PHP version. Your hosting control panel also shows it, usually under a "PHP version", "Select PHP version" or "PHP manager" option.

Note the exact version. You will need it if you have to roll back.

Step 2: Back up everything

Take a full backup of the files and the database, and keep a copy off the server. Many hosts offer one-click backups, and that is fine as long as you know how to restore from it.

The PHP switch itself is reversible, but a broken site can sometimes write bad data, and a plugin update you make along the way cannot always be undone cleanly. A backup covers both.

Step 3: Update WordPress, theme and plugins first

Before changing PHP, update everything else on the current PHP version:

  1. WordPress core.
  2. All plugins.
  3. The theme, and the parent theme if you use a child theme.

Most PHP compatibility problems come from old versions of plugins and themes. The current version usually works on newer PHP. Updating first fixes the majority of issues before they can happen.

While you are there, look for:

  • Plugins not updated in a long time. If the developer stopped maintaining a plugin years ago, it is the most likely thing to break. Find a replacement now.
  • Premium plugins and themes with expired licences. These often sit on old versions because updates need a licence. Renew or replace them.
  • Custom code. Snippets in functions.php or a custom plugin written years ago may use functions that newer PHP has removed.

Step 4: Test on a staging copy

Create a staging copy of the site. Many hosts have a one-click staging feature. Switch the staging site to the new PHP version and test it properly.

Turn on debug logging on staging by adding these lines to wp-config.php:

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

This writes errors and warnings to wp-content/debug.log without showing them to visitors. Then click through the site and check the log.

A testing checklist I use:

  • Home page, a few inner pages and a blog post.
  • Contact forms: submit one and confirm the email arrives.
  • For shops: add to cart, apply a coupon, checkout with a test payment.
  • Log in, and open the main admin screens.
  • Page builder editor opens and saves.
  • Any member area, booking system or custom feature.
  • The debug.log file after all of the above.

Deprecation notices in the log are warnings that something will stop working in a future version. Fatal errors are things that are broken now. Fix fatal errors before moving on, and note deprecations for later.

If your host has no staging, a developer can scan the code for compatibility with a tool like PHPCompatibility, which checks PHP files against a target version. It does not replace testing, but it catches most obvious problems.

Step 5: Switch the live site

When staging is clean:

  1. Pick a quiet time for your traffic.
  2. In the hosting control panel, select the new PHP version for the live site.
  3. Clear any server cache, plugin cache and CDN cache.
  4. Run through the same test checklist on the live site, quickly.
  5. Check the PHP error log in your hosting panel for new errors over the next hour.

Some hosts also let you choose PHP extensions per version. If your old version had a specific extension enabled, such as imagick or intl, check it is enabled on the new one too. A missing extension is a common cause of image or translation problems after the switch.

Step 6: If something breaks

Stay calm. The fix is quick.

What you seeWhat to do
Whole site shows an errorSwitch PHP back to the previous version in the control panel
"There has been a critical error"Check the email WordPress sends to the admin address for recovery mode, or switch PHP back
One feature brokenCheck the error log for the plugin responsible, update or replace it
Admin works, front end brokenUsually the theme; check the log for theme file paths
Blank white pageSwitch PHP back, then debug on staging

Rolling back PHP is a temporary fix. It buys you time to update or replace the plugin causing the problem, then you try again. My guides to fixing the critical error message and the white screen of death explain how to trace the cause from the logs.

After the update

Once the site is stable on the new version:

  • Turn off debug logging on staging, or delete the staging site if you do not need it.
  • Make a note of the PHP version and date in your maintenance records.
  • Set a reminder to check again before the new version's support ends.
  • Replace any plugin that produced deprecation warnings, before the next PHP version makes them fatal.

PHP checks belong in a regular routine with backups, updates and security checks. My WordPress maintenance checklist shows how often to do each.

The short version

Back up, update WordPress and every plugin and theme, test the new PHP version on staging with debug logging, then switch the live site and check the important pages and the error log. If something breaks, switch back in the control panel, fix the cause on staging, and try again.

If you would rather have someone handle the update, or your site is already broken after one, my website bug fixing service covers it. Send me the site address and what you are seeing.

Available for new projects

Need a hand with this?

Tell me what you need: a new site, a fix, a SaaS or an app. You'll get a clear plan and price within a day.

Start a project WhatsApp me