Updating Wordpress without losing settings

How To Update A WordPress Theme Without Losing Customization

Sometimes you need to tweak and customize a WordPress theme. Then you need to be able to update that theme without losing your customizations, so here’s how you do that.

The key to setting this up properly is to use what WordPress calls a ‘child theme’.

What’s a child theme?

A child theme is the active theme for your WordPress site, but it’s a special theme that actually gets nearly all settings and files from a ‘parent theme’. The parent theme is the main theme you chose for you website – i.e. the one that is currently showing as the active theme at the moment.

The aim is to then only apply customizations to your child theme. This leaves your parent theme to be updated without overwriting any changes you have made.

Sidenote: What to update first?

Incidentally, it’s always best (i.e. less risky) to apply updates to your theme and plugins before applying WordPress updates. This is because developers will support older versions of WordPress for some time (typically years) before dropping old deprecated features and functions. If you update WordPress first that can result in older code/functions being removed from WordPress itself that your old theme (or plugin) depends on – something the theme developer will probably have fixed if you apply that change first. If your WordPress site hasn’t been updated in a very long time this can be very tricky to bring up to date and should be done really carefully – see this guide on how to update an old WordPress site – but make plenty of backups before you even attempt it.

So how do we get from your main theme to a parent/child theme setup?

There are a couple of ways – both of which are fairly easy – and I’ll cover them both.

There will however be a bit of extra work if you have already made changes to your parent theme.

Using a child theme creator plugin

There are about 10 different WordPress plugins now that can create a child theme for you. The most popular is Child Theme Configurator but any of them will do the job.

All you do is complete a few details about your child theme and hit a button. This creates a new theme which you will see under the ‘Appearance > Themes’ menu.

Manually creating a child theme

You need to be comfortable creating files and folders on your server and editing code to take this approach.

WordPress have a guide here on the exact steps to creating a child theme. The short version is you create a folder for your child theme, add in a style.css and a functions.php. Your style.css need not have any css in it, but the headers in this file are essential as they define your child theme name and which theme is the parent. The functions file simply enqueues the child stylesheet – everything else comes from the parent theme, for now.

You can now activate your new child theme

After activating your child theme double check your site still looks as it should and that the theme settings are still correct as in our experience some themes lose some settings on activating a child theme. If any aren’t right just set them again, this shouldn’t be necessary in future.

What if I made changes to the main theme already?

You need to move all of those changes to the child theme. If these are stylesheet changes or extra code in functions.php this is just a case of copy and paste. If you have created any extra files such as custom templates, just copy these across to the child theme folder.

If however you have edited any of the main theme files you also need to copy these files over to your child theme folder – but also be aware that the child theme will now use this version only and ignore the file in the main theme folder, even if they get updated with new code in the future (this is something you will need to manage, more below).

How To Update WordPress Theme With A Child Theme

How do I customize the theme in future?

To customize the theme you now make changes to the child theme. Edit the css and functions file in the child theme only – do not edit the main theme files at all.

If you absolutely need to change a main theme file, such as single.php, then you first copy that file into your child theme folder and only edit that copy.

How to update the WordPress theme without losing settings?

All you need to do now to update the WordPress theme without losing any settings is just hit the update button. This will overwrite the main theme files only, and will not touch any of your child theme files at all.

The one thing you do need to be aware of though is if you’ve made fairly significant changes to theme files. If for example you’ve copied and edited actual template files (e.g. header.php or single.php etc) then any changes the theme developer makes to the main theme won’t end up in your customized child theme files. This can mean you miss new features added to the theme or things can break due to the mismatch of files. You may therefore need to manually merge the updated changes into your child theme version along with your own amendments.

Ideally limit your changes to the child stylesheet, functions and your own custom templates. Only override and edit main template files where there is no other option.