Join Morten Rand-Hendriksen for an in-depth discussion in this video What is a child theme, and when is it used?, part of WordPress: Building Child Themes.
- Before we get started, let me answer two important questions. One: what is a child theme? And two: when do we use it? A child theme is an interesting phenomenon in WordPress. You have an existing theme that you really like, but you want to make some changes to it. Now instead of taking that theme and just changing it, or taking the theme, making a copy, and then changing that copy, we create a child theme. The child theme will piggyback on top of the parent theme and introduce changes into the parent theme without actually touching the parent theme in the process.
This has some major benefits. First of all, we can use the child theme to just change small pieces of CSS to change the display of the parent theme in a browser. Second, we can use the child theme to change the output of specific template files, by replacing the parent theme template files with child theme template files. And third, we can use the child theme to augment the output of functions that are available in the parent theme. The end result is you have your own child theme that you manage, and then you're still using the parent theme that someone else built.
You see, if you take a parent theme, and you change the code in the parent theme, and a new version becomes available, and you update that parent theme, you lose all your changes. Same thing happens if you take a parent theme and copy it and then make your changes. Then you'll never be able to get those updates when they become available. However, if you're using a child theme, you'll be able to update the parent theme and keep your child theme and all your alterations intact. Child themes are also an extremely powerful way of learning how to develop themes because instead of developing themes from scratch, you're just building small iterations on top of the parent theme, and you can experiment and see how things work.
And the coolest thing is, if you have a child theme and you do something in the child theme you don't really like or you just want to get rid of it altogether, you can simply delete it, go back to your parent theme, and start over with a new child theme. Nothing is lost, and you can keep working all the time.
WordPress: Building Child Themes opens the world of child theme development to anyone, no matter what level of experience or expertise. It helps you build your child theme on top of an existing properly coded foundation, and create stylish new WordPress sites—without the advanced knowledge of a web developer. Morten Rand-Hendriksen explains how to get started picking a parent theme, updating the CSS, creating a new template for your child theme, and updating its functionality. By the end of this practical, project-based course, you should have a functioning child theme and the skills to quickly customize your next WordPress site.
- What is a child theme?
- Creating and activating a child theme
- Overriding or overwriting?
- Changing existing styles
- Adding new styles
- Creating templates for the child theme
- Adding new menus and widgets
- Replacing custom web fonts