How to update WordPress theme without losing customization
Wondering what is the best way to update a WordPress theme? Worried about losing your currently deployed customization in the WordPress theme?
Well, it is a matter of fact that while updating themes you must be careful, otherwise, you may end up losing all the customizations you have made to your theme.
You can update your WordPress theme using many ways. In this article, we will show you how to easily update a WordPress theme without losing customization. So let’s have a look
How themes are updated in WordPress
WordPress professionals always recommend the owners of WordPress based website to update their WordPress themes to the latest version. WordPress comes with a powerful arrangement that allows the update of plugins and themes as well.
The updates are checked regularly by WordPress and shown under the Dashboard » Updates page. You can also see a notification for theme update at the Appearance» Themes page.
The theme and plugin updates are essential as they bring in security updates, fix bugs and enhance the performance of the theme.
The best part is that you must simply click on the update button to install the new version.
Besides, updates are really important for the security and performance of your WordPress website. Aside from security and bug fixes, theme developers can also introduce new features with these updates.
You can simply click on the update button to install the new version. WordPress will then download the theme package, unzip it, and replace the old files with the newer version. As a beginner, you might have added snippets of code to customize the theme. Well, they do help to customize a theme greatly but that becomes an issue if there is a theme update. You will lose all the changes from custom codes that you had manually added to your WordPress files.
Code for the theme update
You can add the following code snippet to your functions.php file, to update your theme automatically.
add_filter( ‘auto_update_theme’, ‘__return_true’ );
However, it is worth noting that the feature works only for the themes that have been downloaded from WordPress official theme directory. If you’re using WordPress themes downloaded from a third-party website, it is always best to refer the instructions they provide regarding updates.
Customization under Risk
Any code added to the functions.php file would likely be lost. If you had added CSS changes directly to your theme’s stylesheet (style.css), it will also be erased.
Now that we know which changes will be wiped all, let’s check out how we can avoid loss and how to preserve and restore them after the theme update.
However, before that, we would like to recommend that it is always better to back up your site before making any changes on your site or updating your theme. This will help you revert things to normal in case if anything goes wrong. So, let us start.
Use a child theme
In order to enhance the functionalities, most of the beginners customize the CSS or functions.php files and try to tweak their parent theme file. This is a wrong practice to follow. Doing so, there is a risk of losing all the changes made and you may break your website!
Using a Child theme for customization is the safest and best practices of website customization.
If you’re planning only for making slight changes to your CSS files, you don’t need to create a child theme. You can either create a custom CSS file or install and use a plugin such as the custom CSS.
A child theme allows you to make customizations without impacting your theme. It acts as a layer on top of your current WordPress theme and gets its functionalities.
However, updating child themes isn’t as easy as updating the parent themes. As in case of other custom codes, an update to a child theme might erase the custom edits made to it, if it is not upgraded properly. So, unlike parent themes, automatic updates are not suggested in the child theme. Secondly, automatic updates can even make your site broken.
The child themes are normally created by the site owner or the theme developer and can usually come in the theme package. So it is recommended to check if a theme provides child theme documentation before purchasing it.
Updating your WordPress theme to preserve the changes
First of all, you must download your current theme and the latest theme to your desktop.
In the WordPress dashboard, you must use the FTP access to download the theme directly.
After downloading your theme, you must download the latest version of the theme from the official WordPress directory.
Next, if you know all the changes you made, you can just copy them from your old theme to your new theme folder.
But if you don’t remember everything that you did, just download and install a file comparison software to compare your current theme with the latest version. You can use a file comparison software like WinMerge for PC or Kaleidoscope if you are using Mac.
Once you have installed the software, open both the themes on WinMerge to compare. WinMerge will show a list of directories and files in both your themes. It will also show you which files are new and which files are not identical and which ones are new. You can simply click compare to see the changes, then you can copy and paste the changes to the new folder.
Finally, once you are finished with all of that you can upload the new theme with your customizations to your site.
So that was all about updating the theme without using any customizations. So, it is up to you that which method you prefer for a theme update.