You have your WordPress site up and running, you have found a theme you like, have it installed and have modified it to how you want everything to look. You found the custom code you needed to make the color scheme just right or to make the one button in just the right spot. It’s all good and the site is launched. You come back a month or so later and you see a notification in the WordPress admin section about an update for your theme and so you click the update button. Now your colors are back to how they were before you changed them and now that button is back where it was before. What happened?
First, you have to consider what a theme is. According to WordPress, A WordPress theme changes the design of your website, often including its layout. Changing your theme changes how your site looks on the front-end, i.e. what a visitor sees when they browse to your site on the web. So, it will set the overall look of the site, from what colors are used to where everything is on the pages. So, if you change any of the files in the theme when you update the theme, it will override your changes.
I actually had this happen with a customer before. I had added some code changes so that an image would appear on the home page based on the time of day. Once I did an upgrade to the theme, the images disappeared.
So, how did I fix this? A child theme.
What is a child theme?
Well, glad you asked. A WordPress child theme is a WordPress theme that inherits its functionality from another WordPress theme, the parent theme. However, when you make changes that change the colors or where a button is on the page, these changes are made to the child theme so when you update the theme, you don’t override the changes.
It’s also easier to back out of any changes. With a child theme, you make changes to the CSS file for the child theme and the website will reflect these changes. In a child theme, the CSS file will only contain the changes you have made. In make these same changes in the theme, you will have to find that section of the CSS file, which will be considerably larger, and then to find the changes you made and remove them can take a lot more time.
So, in my example, I went into the child theme, made the changes I needed to make, and then, when the theme upgraded again, the changes I had made didn’t get overridden.
How to create a child theme?
Well, you can go the manual route. You will need to login to your hosting account and to go to wp-content\themes, create a folder, and give it a name for your child theme. Then add the necessary files you need for the child theme. For example, style.css and make sure the file has all of the necessary required verbiage in the file.
Or, you can install a plugin like Child Theme Configurator that will create this for you. Once you install the plugin, it will ask which theme you want to create the child theme for and it will create the folder and files for you. You will then activate the child theme and make your changes.
Not all themes will need a child theme.
Some themes now will have a section for you to make your changes and it will keep those changes for you when your theme updates. So you need to determine if your theme needs this or not.
Making changes to a theme can be intimidating but setting up a child theme can have several benefits for your WordPress site and make things a lot easier in making these changes. If you need help in making changes or installing a child theme, please contact us and we will be more than happy to help.