How To Update PHP For WordPress For Faster Site Speeds And Better Compatibility

If you want your WordPress website to be as fast, secure and compatible as possible, one key factor you can‘t ignore is the PHP version it‘s running on. PHP is the server-side programming language that powers WordPress under the hood. And just like WordPress itself, PHP is constantly being updated with new versions that bring performance improvements, security enhancements and expanded capabilities.

As a WordPress site owner, it‘s critical to keep the PHP version your site uses up-to-date. Using outdated PHP versions can negatively impact your site‘s speed, make you vulnerable to security exploits, and lead to incompatibilities with the latest WordPress features and plugins.

In this in-depth guide, we‘ll explain everything you need to know about PHP versions and WordPress. We‘ll discuss the current PHP versions, highlight the benefits of using the latest releases, and walk you through the exact steps to check and update the PHP version on your WordPress site. Let‘s get started!

Understanding PHP Versions and WordPress Compatibility

First, let‘s clarify what PHP actually is. PHP stands for "PHP: Hypertext Preprocessor" (yes, the acronym is recursive). It‘s an open-source, server-side scripting language that can be embedded into HTML to create dynamic web pages. When a web page is requested by a visitor, the PHP code is executed on the server and the resulting HTML is sent to the user‘s web browser.

WordPress is written primarily in PHP, which means the PHP version installed on the web server directly impacts the functioning of a WordPress site. Each major release of PHP is actively supported for two years after its release. During this period, it receives regular security updates and bug fixes. After two years, it moves into the "security fixes only" phase for an additional year before it stops being supported completely.

As of 2023, the current supported PHP versions are:

  • PHP 8.2 (released Nov 2022, active support until Nov 2024)
  • PHP 8.1 (released Nov 2021, active support until Nov 2023)
  • PHP 8.0 (released Nov 2020, active support until Nov 2022, security fixes until Nov 2023)
  • PHP 7.4 (released Nov 2019, active support ended Nov 2021, security fixes until Nov 2022)

Older PHP versions like 7.3, 7.2, 7.1, 7.0 and anything 5.x are no longer supported and should not be used.

WordPress maintains backward compatibility for several older PHP versions. The core WordPress software currently works with:

  • PHP 7.4 (minimum required)
  • PHP 8.0
  • PHP 8.1
  • PHP 8.2

However, just because WordPress CAN run on PHP 7.4 doesn‘t mean it SHOULD. The WordPress team always recommends using the latest PHP version your web host provides. There are major advantages to running WordPress on current, fully-supported PHP releases.

The Benefits of Using the Latest PHP Versions

Each major PHP version includes performance optimizations, security improvements, and new language features. Upgrading your WordPress site to the latest compatible PHP version can have significant benefits:

  1. Increased speed and performance: Newer PHP versions are faster and more efficient at executing code compared to older versions. PHP 7.x versions can handle 2-3 times as many requests per second as PHP 5.6, while PHP 8.0 is on average 18% faster than PHP 7.4. Upgrading PHP can give your WordPress site a major speed boost.

  2. Better security: Newer PHP versions include security vulnerability patches that help protect your site from hacks and exploits. Once a PHP version reaches end-of-life and stops receiving security fixes, any sites using that version become vulnerable targets. Keeping your site on a supported PHP release is critical for security.

  3. Compatibility with the latest WordPress features: The WordPress core team takes advantage of modern PHP language features where possible. As WordPress evolves, some new functionality may require a certain minimum PHP version to work. Staying up-to-date ensures you can use all the latest WordPress features.

  4. Access to a wider selection of plugins and themes: Many WordPress plugin and theme developers specify a minimum (and sometimes maximum) PHP version their code is designed to run on. If you‘re using an outdated PHP version, your selection of compatible extensions may be limited. Newer PHP versions give you access to more and better plugin/theme options.

In short, using the most current PHP version your web host provides is one of the simplest and most effective ways to improve the speed, security and compatibility of your WordPress website. Now let‘s look at how to check and update your site‘s PHP version.

How to Check Your WordPress Site‘s Current PHP Version

Before attempting to update PHP, you need to know which version your WordPress site is currently running. There are a few easy ways to find this information:

  1. From the WordPress admin dashboard, go to Tools > Site Health. Click the "Info" tab and expand the details under "Server". You‘ll see your PHP version listed.

  2. Connect to your WordPress hosting account via Secure-FTP and look for a phpinfo.php file in your root directory. If the file exists, access it in a web browser by appending /phpinfo.php to your domain (e.g. https://www.example.com/phpinfo.php). The resulting page will display your PHP configuration details, including version number.

  3. If your web host uses cPanel, log into your cPanel dashboard. Under the "Software" section, look for the "Select PHP Version" tool. This will show you the current PHP version.

  4. Contact your hosting provider‘s support and ask them which PHP version your account is set to use.

Making Sure Your Web Host Supports the Latest PHP Versions

Once you know your WordPress site‘s existing PHP version, the next step is to find out what newer versions your web host makes available. Most hosting providers allow you to change the PHP version an account uses through the hosting control panel.

However, some budget or restricted hosting plans may not provide the option to use the newest PHP releases. In general, we recommend choosing a hosting company that stays on top of PHP updates and makes new versions available to customers soon after they‘re released.

Check your hosting plan‘s features or ask your host‘s support team which PHP versions they currently support. If the newest PHP 8.x releases aren‘t an option, you may want to consider upgrading your hosting plan or switching to a more proactive provider that keeps pace with PHP development.

How to Update PHP in cPanel

Updating your WordPress site‘s PHP version is usually a simple process that can be done through your hosting account‘s control panel. Most web hosts use cPanel, so we‘ll provide instructions for that interface here. If your host uses a different control panel, the process will be similar but the specific steps may differ slightly.

Here‘s how to update your PHP version in cPanel:

  1. Log into your cPanel dashboard.

  2. Look for the "Software" section and click the "Select PHP Version" tool.

  3. On the next screen, choose the domain you want to configure from the drop-down menu.

  4. You‘ll see a list of PHP versions your host supports. Select the radio button next to the newest PHP version available.

  5. Click the "Set as current" button to apply the PHP version change.

That‘s it! Your WordPress site is now using the new PHP version you selected. But before you celebrate, there‘s one more critical step.

Testing Your Site After a PHP Version Update

While upgrading PHP is usually problem-free, in some cases you may experience issues after making the switch – especially if you‘re jumping from a very old version to the latest release. Newer PHP versions may deprecate or remove functions that your WordPress theme or plugins relied on. This can lead to errors or unexpected behavior on your site.

Before updating PHP on your live production website, we strongly recommend testing the new version thoroughly on a development site or staging environment first. Clone your WordPress site to a separate testing location and perform the PHP version update there.

Then put the testing site through its paces:

  • Thoroughly navigate through the pages and posts, looking for any display or formatting issues.
  • Test all critical site functionality like contact forms, ecommerce checkout, search, etc.
  • Try out all the WordPress admin dashboard functions to make sure nothing is broken.

If everything looks good on the development site after upgrading PHP, it should be safe to apply the update to your live production site. We still recommend having a current backup of the live site on hand before making the change in case anything goes wrong.

Useful Tools for Checking PHP Compatibility in WordPress

Sometimes theme or plugin code isn‘t fully compatible with newer PHP versions. If you encounter issues after upgrading PHP, these WordPress plugins can help you track down the source:

  • PHP Compatibility Checker: This plugin analyzes your WordPress site‘s theme and plugins for compatibility with different PHP versions. It will identify any deprecated functions or incompatible code.

  • Debug Bar: This plugin adds a debug menu to your WordPress admin bar that shows query, cache, and other helpful debugging information.

  • Query Monitor: This WordPress plugin shows debugging and performance information on database queries, PHP errors, hooks and actions, block editor blocks, enqueued scripts and stylesheets, HTTP API calls, and more.

Keeping Your WordPress Site Up-to-Date for PHP Compatibility

One of the best ways to avoid running into PHP version incompatibilities is to keep your entire WordPress site up-to-date. That means using the latest versions of:

  • The WordPress core software
  • Your active theme
  • All your installed plugins

Reputable theme and plugin authors maintain their code to be compatible with new PHP versions as they‘re released. Sticking with extensions that are regularly updated will go a long way towards avoiding PHP-related issues on your site.

The Importance of Regular PHP Updates for WordPress

As a WordPress site owner, you should get in the habit of upgrading your PHP version on a regular basis – not just one time. Each time a new PHP version is released, make a plan to test it and upgrade your site as soon as your host makes it available.

This ongoing PHP maintenance is just as important as keeping your WordPress core, themes and plugins updated. It ensures your site is always running at peak performance and protected by the latest security patches.

Conclusion

Updating the PHP version your WordPress site uses is a critical maintenance task that has major benefits for speed, security and compatibility. We recommend using the latest PHP version your web hosting environment provides.

The steps to check your current PHP version and upgrade to a newer release are straightforward:

  1. Find your WordPress site‘s existing PHP version via the Tools > Site Health screen, phpinfo.php file, or hosting control panel.

  2. Verify that your web host supports the newest PHP 8.x versions.

  3. Make a complete backup of your WordPress site.

  4. Clone the site to a development/staging environment for testing.

  5. Perform the PHP version update in your hosting control panel.

  6. Thoroughly test your staging site for any issues with the new PHP version.

  7. If everything works on the staging site, apply the PHP update to your live production site.

By keeping your WordPress site on the most current, supported PHP version at all times, you‘ll ensure peak performance, security and compatibility. You‘ll be able to use the latest features and functionality of WordPress core, themes and plugins. And you‘ll enjoy faster site speeds from PHP‘s code execution optimizations.

There‘s no reason to let your WordPress site lag behind on outdated PHP releases. Follow the steps in this guide to update your PHP version today!