If you are not running the most recent version of PHP, you are hurting the load speed of your WordPress website. Studies have shown that any website that takes more than 6 seconds to load will be abandoned by 53% of people that visit it. That’s huge! That’s why you need to learn how to update PHP in WordPress.
Updating the PHP version of your website is one sure way of improving site load speed. Even more, it lessens the chances of hackers gaining access to your website.
In this article, we’ll show you how to update PHP on WordPress to the latest version.
- WordPress and PHP
- The Benefits of updating to the Latest Version
- What to do Before Updating
- Methods for Updating
- What to do if Updating PHP Breaks your Site
PHP and WordPress
Do WordPress sites use PHP? A lot of beginners ask this question. The answer is yes! WordPress was built on PHP, a server-side scripting language. WordPress has undergone several updates ever since the very first version – also has PHP.
What that means is that if you run the latest version of WordPress on an outdated PHP version, you are very likely to run into problems.
Update the PHP To The Latest Version – Benefits
1. Improved Security
PHP is an open-source programing language. WordPress, as well, is open source. This makes them very popular – and also potential targets for hackers. To safeguard your website from hackers, upgrading to the latest version of PHP is a must. This is not to say that older versions -like PHP version 5 – completely lack security features, they aren’t secure enough to keep away a determined hacker.
2. Improved Load Speed
While there are many techniques you could use to improve the load speed of your website, updating to the latest PHP version is one sure method. The most current version of PHP is three (3) times faster than the older version.
3. Improved SEO
Load speed is one of Google’s ranking factors. A faster website means a higher ranking in search results, improved user experience, and more sales!
What to do Before Updating PHP
Here are a few things to do before updating PHP.
Backup Your Site
Before doing any update in WordPress, it’s always advised to create a backup. The same is applicable when updating the PHP version of your WordPress website.
Here are two major reasons why creating a backup before updating to the latest PHP is important.
- WordPress themes and plugins are also written in PHP. If any of the plugins or your theme is badly scripted, there will be compatibility issues once the update happens.
- Something might go wrong during the updating process. A typical example is the loss of internet connection. As minor as the issue looks, it could lead to a catastrophic outcome in some cases.
To prevent these possible problems from ruining your site, back up your website before making any updates. It’s easy!
Update plugins and themes
There are chances that your plugins and themes may not be compatible with the latest version of PHP.
To prevent this from happening, you should update your WordPress plugins and themes to the latest versions.
For this, log in to your WordPress dashboard. Next, go to Dashboard >> Updates. Here, install any/all available updates.
Check PHP Compatibility
After activating the plugin, go to Tools >> PHP Compatibility. Next, select the latest version of PHP.
You may choose to scan only active plugins/themes or scan everything. Lastly, hit the Scan site button.
The plugin takes it from here. It scans and identifies any compatibility issues between PHP and your plugins/themes.
If there is a problem, you may either let go of the plugin and search for an alternative one or contact the plugin developer to fix the compatibility issue.
Note: At the time of making this post, the plugin only scans up to PHP 7.3. If you need to check for compatibility with PHP 8 and above, we recommend testing the update on a staging environment before pushing it to your live site. Please check this guide to learn how to create a staging environment for your WordPress site.
Now that you’ve seen the benefits of updating to PHP’s latest version and have hopefully backed up your website, let’s show you how to update your PHP version.
How to Update the PHP Version of your Website
There are two ways to go about this: through your control panel (cPanel in this example), and by contacting your host provider.
1. Update PHP version in Cpanel (or Any Other Control Panel)
Log into the control panel of your hosting provider. Under, the “Software” tab, click on Select PHP Version.
On the next page, you will see the PHP version your web server is using.
Now, click on the current PHP version and then select the latest version from the drop-down.
Lastly, click on Set as Current. You are all done!
2. Contact Your Host Provider
What if the PHP Update Breaks my Site?
If you run into any error while updating your PHP version you can always restore the last backup you made. This is why we recommended you backup your site at the beginning.
However, if the update is causing your website not to load, it could be due to a conflict with your plugin or theme. It occurs when some of the functions on your plugin are written using an older version of PHP.
To resolve this, you may need to troubleshoot your plugins and theme to find the culprit.
For plugins, deactivate all plugins and check if your site comes back. If it does, then one of your plugins is the culprit. To find the faulty plugin, begin activating your plugins one at a time. Each time, confirm that your site is working.
The plugin you activated just before your site goes down is most likely the culprit. Simply deactivate the plugin and sort for an alternative plugin.
If at this point your website is still not loading, you may want to revert back to an older PHP version for your WordPress site. After that, contact your hosting providers or hire a professional to assist you in updating your WordPress sites’ PHP version.
What Next After Updating PHP in WordPress?
After updating your PHP, ensure you update WordPress to the most recent version as well. You also want to update your themes and plugins to prevent compatibility issues. Finally, visit your website and confirm that everything is working as it should.
The tech world is continually changing. Every day, there is a new update for something. WordPress and PHP, being two very popular website resources, get regular updates that would keep your site running at its best.
Once you have changed the PHP version of your website, you can enjoy the higher speed, security, and other features that come with the newest version.
- Remove Query Strings from Static Resources – 2 Methods
- How to Move WordPress Site to New Domain
- Complete WordPress Multisite Network Guide