You need to pick a PHP version for your WordPress site from 8.2 through 8.6, and you don't want the switch to break anything. WordPress recommends PHP 8.3 or higher, while WordPress itself works as far back as PHP 7.4.
Picking the right version comes down to balancing WordPress's recommendation against what your themes and plugins can run. Each PHP release branch gets two years of active support and two more years for critical security issues only, so you don't have to guess blindly.
Check which PHP version your site runs now
Open your WordPress Dashboard and select Tools > Site Health from the sidebar menu, then select the Info tab. Expand the Server section and scroll down to see which PHP version your site runs right now.
If that number is at or higher than PHP 8.3, you don't need to update PHP right now. If your site runs an older version lower than 8.3, you may see a PHP Update Required or PHP Update Recommended notice on the Dashboard or in Site Health.
Here's the catch: your hosting company determines which versions of PHP are available for your site, and many hosters let you change this yourself.
How PHP support branches narrow down your choice
Each release branch of PHP is fully supported for two years, during which issues are fixed and regular point releases are made. After that, the branch is supported for two additional years for critical security issues only, with releases made on an as-needed basis.
Once the four years of support are completed, the release is no longer supported and may be exposed to unpatched security vulnerabilities. Keep your target on PHP's Currently Supported Versions list: 8.2, 8.3, 8.4, 8.5, or 8.6.
- PHP 8.2 sits on PHP's Currently Supported Versions list, though it is lower than WordPress's recommended 8.3 or higher.
- PHP 8.3 meets WordPress's recommended version of 8.3 or higher, which can deliver a performance increase for all visitors, while older versions lower than 8.3 lack the latest security features.
- PHP 8.4, 8.5, and 8.6 are also on PHP's Currently Supported Versions list if your themes and plugins work on them.
The tricky part is that WordPress itself works with PHP as far back as version 7.4, and WordPress cannot tell you whether your themes or plugins will work on newer versions.
Check your plugins and themes before switching PHP
Open the Updates page under Dashboard > Updates and update WordPress, your themes, and your plugins first. Check that your site still works as expected before you touch PHP.
Next, check when each theme and plugin was last updated on its WordPress.org page to make sure it is actively maintained. If one looks unmaintained, look on WordPress.org for themes or plugins with similar functionality and use one of those instead.
Checking update dates tells you whether a plugin is actively maintained, not which files use removed PHP features. To check the files installed on your site, I use Bright Labs Compatibility Scanner for PHP, a free plugin we build at Bright Labs and publish on WordPress.org. It reads every installed plugin and theme inside WordPress in short steps, needs no exec() and no shell access, and lists each file and line using something removed or deprecated in PHP 8.2 through 8.5.
Once you switch PHP, you can also enable Check offered updates before they install under Tools > Bright Labs Compatibility Scanner for PHP > Settings. It is off by default. When on, it checks offered updates against your PHP version and warns on Dashboard > Updates and the Plugins screen if it finds errors, without stopping, delaying, or changing an update.
Treat a clean scan from Bright Labs Compatibility Scanner for PHP as one check, not proof that your site will run without errors. Because our scanner reads plugin and theme files without running them, it can miss problems in code built at runtime and flag code paths that never run. You still need to test on staging.
Test your chosen PHP version on staging with debug logging
Make a backup first so you can revert your site if anything goes wrong. This one is easy to miss: if you need to restore that backup after a failed PHP switch, contact your host and ask them to restore your previous PHP version before you restore the backup.
If your hosting company offers a staging site, update PHP there first and test your site before updating your live site. On staging, turn on WordPress's debug constants in wp-config.php so errors save to debug.log in the content directory while staying hidden from visitors.
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );
Watch the quotes in wp-config.php: keep false unquoted. Wrapping false in quotes turns it into a string, so PHP interprets it as true instead. Do not use WP_DEBUG or the other debug tools on a live site, because WordPress means them for local testing and staging installs.
Click through your key pages on staging, then check debug.log in your content directory. Look for an error reading Call to undefined function, which can mean a plugin is trying to find a file or data or that you are running an incompatible plugin or theme.
Recover fast if a PHP switch breaks your site
If switching PHP triggers There has been a critical error on this website. Please check your site admin email inbox for instructions., restore your previous PHP version first. Contact your host and ask them to restore the previous PHP version if you cannot change it yourself, then restore your backup.
To find what broke, check your site admin email inbox and read debug.log. WordPress lists plugin conflicts, theme compatibility issues, running an incompatible PHP version, hitting the memory limit, and corrupted WordPress files among the common causes of a critical error.
- If you can access the Administration Screens, try deactivating all of your plugins and reactivating them one by one.
- If you cannot access your admin screens, log in via FTP, find wp-content/plugins, and rename the plugins folder to plugins_old.
- If plugins are not the cause, rename the folder for the active theme via FTP to isolate theme errors.
- If you see Maximum execution time of 30 seconds exceeded or Maximum execution time of 60 seconds exceeded on shared hosting where you cannot make changes yourself, ask your hosting provider to increase your maximum execution time.
Sources
- {'text': 'WordPress.org PHP update guide and checklist', 'url': 'https://wordpress.org/support/update-php/'}
- {'text': 'PHP official supported versions and lifecycle', 'url': 'https://www.php.net/supported-versions.php'}
- {'text': 'WordPress Developer Handbook debugging configuration guide', 'url': 'https://developer.wordpress.org/advanced-administration/debug/debug-wordpress/'}
- {'text': 'WordPress Developer Handbook common errors troubleshooting', 'url': 'https://developer.wordpress.org/advanced-administration/wordpress/common-errors/'}
Frequently Asked Questions
What PHP version does WordPress recommend right now?
WordPress recommends PHP 8.3 or higher for a performance increase, and the latest version includes the latest security features, while WordPress itself still works with PHP as far back as version 7.4.
How long is each PHP release branch supported?
Each PHP release branch gets two years of active support with regular point releases, followed by two additional years for critical security issues only before reaching end of life after four years.
Does a clean compatibility scan prove my site will work after a PHP update?
No. Bright Labs Compatibility Scanner for PHP reads plugin and theme files without running them, so it can miss runtime-built code and flag code that never executes, and WordPress cannot tell whether your themes or plugins will work on newer versions. Update PHP on a staging site first if your host offers one.
How do I recover if switching PHP causes a critical error?
Change back to your previous PHP version if your host lets you, or contact your host and ask them to restore it, then restore your backup. If you cannot access your admin screens, log in via FTP and rename wp-content/plugins to plugins_old to deactivate plugins.
Originally published on Bright Labs.
Top comments (0)