Is WordPress compatible with PHP 8?

Looking for updated information?
Visit the Hosting Handbook Server Environment page.

TL;DR. If you are using WordPress 6.2, you should at least use PHPPHP PHP (PHP: Hypertext Preprocessor) is a general-purpose scripting language especially suited to web development. PHP code is usually processed on a web server by a PHP interpreter. On a web server, the result of the interpreted and executed PHP code would form the whole or part of an HTTP response.PHP PHP (PHP: Hypertext Preprocessor) is a general-purpose scripting language especially suited to web development. PHP code is usually processed on a web serverServer A server is a piece of computer hardware or software that provides functionality for other programs or devices. Typical servers are database servers, file servers, mail servers, print servers, web servers, game servers, and application servers. by a PHP interpreter. On a web server, the result of the interpreted and executed PHP code would form the whole or part of an HTTPHTTP The Hypertext Transfer Protocol (HTTP) is protocol for distributed, collaborative, hypermedia information systems. HTTP is the foundation of data communication for the World Wide Web, where hypertext documents include hyperlinks to other resources that the user can easily access, for example by a mouse click or by tapping the screen in a web browser. response. 8.1. If you keep your WordPress, plugins and themes up to date, everything should work fine.
If you are not yet using WordPress 6.2, we strongly recommend that you use this version of WordPress for maximum PHP compatibility.

PHP 8.x has been with us for a while now, so much so that even PHP 8.0 has only security support, and we should mainly use PHP 8.1 and PHP 8.2.

It mainly depends on which versions of WordPress and PHP we are talking about. There are many places to get information about WordPress and PHP compatibility:

A lot of information, plenty of versions.

The official version

WordPressPHP compatiblePHP beta compatible
WordPress 6.25.6 – 7.48.0* / 8.1* / 8.2*
WordPress 6.15.6 – 7.48.0* / 8.1* / 8.2*
WordPress 6.05.6 – 7.48.0* / 8.1*
WordPress 5.95.6 – 7.48.0* / 8.1*
WordPress 5.85.6 – 7.48.0*
WordPress 5.75.6 – 7.48.0*
WordPress 5.65.6 – 7.48.0*

What does beta mean?

Nothing. Yes, really, nothing. Forget about that!

When PHP 8.0 was released, WordPress gave some warning messages (not error messages). Most of those messages are fixed in all versions of WordPress and for all versions of PHP. Yes, there are outstanding tickets and messages, but they are few and should not affect WordPress performance.

Why put the beta label, then?

Not because of WordPress, but because of the ecosystem, i.e., plugins and themes. When PHP 8.0 appeared, block themes were not yet widespread and the Site Editor was not yet finished, which it is now. And since WordPress did not make its compatibility clear, many plugins were not adapted to PHP 8.x… because what’s the point if WordPress is non-compatible? (yes, this last question is pure sarcasm).

And, the fish that bites its tail: WordPress says it’s beta-compatible, and plugins and themes don’t adapt because WordPress isn’t… but, it’s not true. You have to read the fine print.

It’s all a matter of timing

In some cases, the release of WordPress coincides with a new major version of PHP, and that complicates everything. On the one hand, there is no time to adapt, on the other hand, everything works. And between one and the other, things are left the same.

The fact of marking WordPress as beta-compatible had a reason to be: WordPress works, but in general nobody uses WordPress without plugins. And the plugins, most of them, were not adapted to PHP 8.x.

It has been 6 months since the release of PHP 8.2 and many plugins are still not supported… although there has been time for PHP 8.0 and 8.1 to be supported.

Again, it’s a timing issue. PHP started a few years ago a cycle of annual releases of major versions that are not fully compatible with each other or generate many warnings, and reviewing all the WordPress code is complex, let alone the more than 60,000 plugins and 10,000 themes.

The Hosting vision

Security is a critical factor for hosting companies, and keeping PHP versions up to date is part of that.

That is why, every year, as the old PHP versions are no longer officially supported, the providers are activating the new ones and deactivating the old ones.

While it’s true that there are no PHP 7.4.1+ vulnerabilities reported yet (it’s a matter of time), it’s about time to use at least PHP 8.0. And, almost already, for the remaining half year of support, you should consider using at least PHP 8.1.

WordPress vs. PHP vs. Hosting companies

Undoubtedly, the decision to use one or another version of PHP for each project should be up to the users, although the hosting companies should clearly inform about the risks or not of using one or another version.

For example, someone with WordPress 5.8 cannot be recommended to activate PHP 8.1 because it probably won’t work. Nor can you push to make the change as soon as a new version of PHP is released.

What should I do?

First: the decision must always be yours. It is your project, and you have to decide what is best for it with all the information.

Second: have all the information. And this is where we can help you, a little.

Third: everything has to work. The goal is to make your site work, so you have to check, with a staging version, that everything is working properly. Ask your hosting provider for help with this.

I have WordPress 6.2

Presently, in May 2023, our recommendation is that you have at least PHP 8.1. It is a stable version, it is a secure version, and most themes and plugins work with this version.

WordPress 6.2 is compatible with 5.6.20+, PHP 7.0.x, PHP 7.1.x, PHP 7.2.x, PHP 7.3.x, PHP 7.4.x, PHP 8.0.x, PHP 8.1.x and PHP 8.2.x. BUT, older than PHP 8.0 are nor maintained, PHP 8.0 has only security maintenance and PHP 8.1 and PHP 8.2 are maintained versions. This is why PHP 8.1 is a good choice because, in general, everything should work.

What do I do if something doesn’t work? Upgrade everything to the latest versions. The latest version of WordPress 6.2 (right now WordPress 6.2.0), the latest versions of all your plugins and all your themes. If you have premium plugins, make sure you have the latest versions. Ask your hosting to help you figure out what’s wrong.

I have WordPress 6.1

When we published Server Environment for WordPress 6.1, we knew that WordPress 6.1 worked correctly with PHP 8.0 and PHP 8.1. PHP 8.2 did not, for one simple reason: it had not yet been released.

We also knew one thing: most plugins, even though PHP 8.1 had been on the market for a year, were not fully compatible. It was after PHP 7.4 stopped receiving updates that many developers started to support all available PHP 8.x versions, which are PHP 8.0, PHP 8.1 and PHP 8.2.

It has been long enough for WordPress 6.1, its plugins and themes to work properly with PHP 8.0 and PHP 8.1.

And, just as with WordPress 6.2, if you still have WordPress 6.1 everything should work correctly with PHP 8.1.

I have WordPress 5.9–6.0

You can read the same as in the two previous cases. In short, you should now be able to upgrade everything to PHP 8.1.

I have WordPress 5.6–5.9

You can read the same as in the two previous cases. In short, you should now be able to upgrade everything to PHP 8.0.

I have a version before WordPress 5.6

Surely, the best thing to do is to check out our article Upgrading (very old) WordPress.

Summary

The Core, Test, and Hosting teams actively care about the full compatibility of WordPress with all its technologies. This includes Apache HTTPD, nginx, PHP, MySQL, MariaDB, memcached or Redis.

While it is true that PHP is a critical technology, we have a project in which many hosting companies test their systems with future versions of WordPress so that, once released, its compatibility is as high as possible.

You can see the results of Host Test Results and learn how well it works and what the bugs are. Errors are good because it means that a possible incompatibility has been detected and will be corrected in the future so that WordPress remains compatible with the widest number of systems.

And if you are a hosting company, you can help WordPress stay up-to-date by testing alpha versions on your systems.

#core, #php