How To Update a WordPress Theme Without Losing Customization
One of the many great advantages of using WordPress as your content management system is the possibility to customize nearly any part of your website. This could be done using various methods: with built-in WordPress settings, third-party plugins, theme options, and even custom code. While each of those methods has its unique set of benefits, risks, and limitations, using custom code snippets can potentially cause the most issues for your WordPress website.
Custom code snippets can seem scary. If used improperly, they can break your website, and maintaining them against theme updates can be quite challenging. If you place code snippets directly inside the files of your WordPress theme, chances are very high that they will be lost after you performing the next theme update. And this can make WordPress users wary of performing theme updates at all, which is far from recommended. Updating your WordPress theme has multiple benefits and, if done properly, no added customization will be lost. In this article, we’ll explore how to update a WordPress theme without losing customization and answer the following questions:
Updating a WordPress site involves updating the WordPress core files, plugin files, and theme files. In this article, we’ll focus on covering the process for updating a WordPress theme. Before we delve into the how-tos of this article, let us discuss the reasons for updating your WordPress theme.
Updating a WordPress theme is crucial in maintaining its compatibility with the latest versions of WordPress. Even though this is far less common than with plugins, compatibility issues between your theme and the latest version of WordPress can occur. To avoid this, theme developers will issue theme updates that address the potential problems. Therefore, it is important to be on the lookout for new theme updates after WordPress updates, especially major ones. This will ensure your website is fully compatible with the latest version of WordPress and that it can continue operating smoothly.
Additionally, WordPress theme developers regularly improve their code and implement new features. These WordPress theme updates will often contain solutions to any reported issues or code improvements in general. Apart from that, theme updates could contain new features that users have flagged as potentially useful. All of this incentivizes WordPress users to perform theme updates so as not to miss out on all the improvements that were made.
Finally, theme updates may contain code that addresses any security vulnerabilities that were uncovered. Since WordPress has a widespread, open community, security vulnerabilities are caught relatively quickly. Furthermore, since website security is highly prioritized today, these security vulnerabilities are solved with the utmost urgency and the fixes are included in theme updates.
There are more than enough reasons to keep your theme up to date. And the benefits of doing so outweigh the drawbacks by far. Now, let’s explore how WordPress theme updates may affect any added customizations.
Qode Themes: Top PicksView Collection
There are a multitude of ways you can add customization to your website. And it’s important to know beforehand which of those ways may be negatively affected by a theme update. Let us discuss all the customizations that won’t get affected first.
Any customizations that were made using the options provided by the theme won’t be affected. This includes any options located in the WordPress > Customize section or any option-specific section created by the theme, which is displayed within the admin dashboard.
This also extends to any plugins that were included with the theme and that are required for it to work properly. Both the option choices you made and the content you created with those plugins won’t be affected by a theme update. Moreover, the settings of all plugins you use on the website will be safe against theme updates. And any customizations you have made to your website’s layout using these plugins will be intact, as well. This includes any editing you have done to your pages using page builders, contact form plugins, or any other plugins which offer custom shortcodes that you can simply drag and drop to create adequate page content.
Finally, your menus won’t be affected by the update, nor will any of the widgets you’ve used on your website. The reason why all these customizations aren’t affected by a theme update is that they are stored in their respective tables within your database. Therefore, as long as you don’t edit the database, all the above-mentioned customizations will be preserved.
However, this brings us to the type of website customizations that are affected by theme updates. During a theme update, the theme files get overwritten by newer versions of themselves, and any customization that was added directly inside the older theme files is lost. This includes any CSS, JS, or PHP code that you’ve added directly inside one of the theme’s files.
For example, if you added CSS code inside the style.css file or added PHP or other type code inside the functions.php file of your parent theme, it will be lost after an update. Therefore, you should avoid directly changing your theme files. Apart from the customization being lost, you might also cause some compatibility issues with your website.
Furthermore, you should refrain from directly changing any WordPress-related files, i.e. WordPress Core files, plugin files, or theme files. But, if you’ve already done something to those files, don’t worry, we’ll explain how to preserve your customizations in the following section.
Now that you understand the benefits of updating a theme and what customizations may be affected by the update, let’s explore how to properly update a WordPress theme. We divided the update process into two parts—the preparatory steps and the update itself. Both are important in ensuring no customizations made to the WordPress website are lost.
Furthermore, the safest option would be to set up a staging website and perform the update process on it. We recommend you do that if you can, as this will protect your actual website from any unforeseeable issues during and after the update. With that being said, let’s begin.
Steps you should take before updating the theme
Since we will be discussing how to manually update the theme via FTP, the first step you should take is to brush up on how to use FTP if you aren’t familiar with it already. Alongside that, you will need to transfer all the coding customizations you added inside your theme files to a more secure location. Otherwise, the theme’s template files will get overridden in the update, and any customization you added to them will be lost. However, if you haven’t added any such custom code modifications into your theme’s files, then, you can simply skip to the updating process.
To transfer your custom code, you will first need to download your theme’s folder. We will show you how to do it in just a few steps within cPanel. In case you don’t have cPanel as your control panel, we suggest asking your hosting provider for help.
First, log in to cPanel using your cPanel credentials and click the File Manager option located within the Files section near the top of your screen.
Find your website in the list on the left and navigate to your root WordPress directory, often called public_html.
Then, navigate to the wp-content/themes directory and locate your current theme’s folder. Since regular folders don’t have a Download option, we will first compress the theme directory and then download it. To do this, right-click on the folder and select the Compress option from the dropdown menu that appears.
Within the popup window that appears, select Zip Archive as the Compression Type and press the Compress File(s) button to compress the folder.
Shortly after, the folder will be compressed and you will see the results of the compression. To continue, press the Close button at the bottom of the Compression Results popup window.
Finally, to download the zipped folder, find where it is within the wp-content/themes directory. It will be titled theme-name.zip, with the theme-name part replaced by the actual theme name. Right-click on it and select the Download option from the dropdown menu that appears.
The zipped file will, most likely, be put inside your Downloads folder. Locate it on your computer and extract it wherever you like.
The downloaded folder will help you track all the modifications you added so that they could be transferred onto a more secure location, such as inside a child theme or a site-specific plugin. In this article, we will focus on transferring the customizations to a child theme.
If you don’t already have a child theme for your current theme, you should create a child theme now and install it. Our article on creating child themes also shares tips on how to add customizations to them, which is our next step.
If you remember all the changes you’ve added to the parent theme files, you should copy them and paste them within the child theme’s folder. If the modifications are snippets of PHP code, i.e. custom functions, they should be added inside the functions.php file of the child theme. Similarly, any CSS that you added to the parent style.css file should be transferred either into the style.css file of the child theme or into the Appearance > Customize > Additional CSS section.
On the other hand, if your modifications involved changing several template files or the creation of new ones, then you should recreate this customization in full. Meaning, you should recreate the files, as well as the folder structure they were in. Make sure to fully match the folder structure that was present in the parent theme inside the child theme folder.
However, if you made a lot of changes, you might not remember all the customizations added to the theme. In that case, you should download the latest theme version and compare its files with the files of the theme folder downloaded from the server. Using file comparison software like WinMerge, Kaleidoscope, or Meld will help you go through the files quickly.
After figuring out all the modifications that you made to the old parent theme, you should recreate them inside the child theme’s folder, as mentioned above. After you’ve done that, you should test your website to see if the customizations you have transferred onto the child theme folder are working as before. Don’t forget to enable the child theme during the testing process and make sure to clear any browser or plugin cache to ensure you’re seeing up-to-date information.
After safely storing all the custom modifications inside a child theme, you can proceed to update the theme. Before we begin with the process, there are two remarks we want to share. First, we strongly encourage making a backup of your website at this point. This will ensure no harm is done to your site if an issue arises after the update. Second, the process we describe below is best suited for themes that are part of the WordPress themes directory. If you’re using a premium theme, the update procedure may differ. In that case, the best course of action is to consult your theme’s authors first and ask them about the proper way to update the theme.
To update a WordPress theme, you will need to download its latest version, if you haven’t done so already. Then, make sure to unzip the downloaded folder, as you will need to upload its files via FTP.
Once you’ve done that, connect to your server using your FTP credentials and navigate to the root WordPress directory of your website.
Next, navigate to the wp-content/themes directory. You should do this within the right-side window of your FTP client, which represents the remote side, so it shows the file and folder structure on your server.
Then, on the left side of the FTP client, locate the folder with the latest version of your theme. The left side will show the folder and file structure of your local computer, so make sure to find the folder that you downloaded and unzipped earlier. After that, right-click on that folder and select the Upload button from the menu that opens.
At this point, the FTP client will display a Target file already exists message. Since you are uploading a newer version of the same files that are on the server, and they have the same names, this message is nothing to be alarmed about.
In the update process, the newer theme files are supposed to overwrite the older theme files. And, since you transferred any custom code modifications into a child theme folder, nothing will be lost and you will be able to enjoy all the improvements and bug fixes that the new update brings. Therefore, simply choose Overwrite as the action and press the OK button. You can also select the Apply to current queue only option. This way, you avoid repeating the overwrite action confirmation for future files.
You will need to wait until all theme files are uploaded to the server. When it’s done, your theme will be updated. We advise reviewing your website and ensuring there are no issues after the update.
Performing WordPress theme updates regularly is important for several reasons. Those include maintaining compatibility with the newest WordPress versions, fixing security issues, and improving your website overall. However, if you made some custom modifications to the themes files, a forthcoming update can be quite stressful. So, in this article, we aimed to show you how to update a WordPress theme without losing customization.
This involves transferring your custom code inside a child theme and performing the theme update via FTP afterward. Hopefully, this article will make your future theme, plugin, and WordPress updates stress-free.
Post your comment