In this post, I’ll explain what a WordPress child theme is, when you should use one, and how to create one for your site in just a few clicks.
In the WordPress-world, the topic of child themes is a bit mysterious. What are they? When do you need them? My colleagues in web development and clients who work on WordPress ask me to explain it to them constantly. In the next few paragraphs, I’ll try to explain what a child theme is so you can decide whether you need one or not.
Have you ever been in this situation?
You want your theme to do something it doesn’t. Maybe you want a search button in the menu or a count of all the posts each user has made on a bbPress forum that shows up on their profile. You search for a plugin to do the job, but come up empty handed. So you turn to Google, and come across a forum or tutorial where someone provides a bit of code and suggests you add it to something like “functions.php.”
It’s easy enough at this point to just go to your site’s dashboard, then click on Appearance and Editor, find functions.php, and paste in the code.
But, you shouldn’t.
When your theme developer updates your theme, either for security or to provide some new tools, running that update on your site will completely erase any changes you’ve made to any PHP files in the theme.
You’ll end up having to dig up that old tutorial so you can find the code and add it back in, which isn’t a good use of your time or effort. You have a business to run, after all. This is where child themes come in.
What’s a child theme?
A child theme is similar to regular WordPress themes. Once you have one, you’ll see it listed under Appearance > Themes just like any other theme.
However, where a normal WordPress theme would have lots of code that provides the functionality and design of the theme, a child theme is almost empty.
The only thing a child theme contains is a short line of code telling it to get all of its design and functionality from another theme.
Using a child theme is like duplicating your current theme, but instead of copying all of its code into the new theme, you just refer back to it.
When should you use a child theme?
The big benefit of a child theme is any PHP or other code you add to the theme won’t be overridden when its “parent” theme has an update.
Anytime you want to edit a file in your theme that ends in .php, you should be using a child theme.
How can you create a child theme?
Most premium paid WordPress themes, like those purchased from a theme developer’s website or from somewhere like Themeforest.com will come with child themes. If your theme already has a child theme, just install it the same way you installed the original theme.
However, some paid themes and most free themes don’t have child themes available. You’ll have to make your own.
The WordPress Codex has a great tutorial on creating child themes. You’ll have to write some PHP, but, even if you’ve never seen PHP in your life, it’s not very difficult. This is a good option if you want to try something technical and learn a little bit about how WordPress works.
For an easier path, you can use the One-Click Child Theme plugin by tychay. Don’t be deterred by the fact that this plugin hasn’t been updated in 2 years – it still works beautifully. (I discussed some key ways to identify potentially problematic plugins here. Outdated plugins is one of the main things to look out for.)
Once you’ve installed and activated the plugin, using it is simple:
- From your site’s Dashboard, navigate to Appearance > Themes.
- Click on the theme you’d like to create a child theme of (usually the theme you’re currently using).
- At the bottom of the pop-up window, click Child Theme.
- Fill in the Name, Description, and Author information here. This can be anything you’d like, but here’s how I usually do it:
- For Name, I choose something like the theme name + “child.” If I were making a child theme for my business, I might just call it “Just Peachy Theme”
- For Description, I write something like “A child of the (theme name) theme by (theme developer’s name).”
- For Author, I fill in my own name.
- Click Create Child.
You’ll see your new child theme listed right on your Themes page, along with any other themes on your site. Now you can Activate it and begin adding your own custom PHP.
Do you have lingering questions about child themes? Other reasons you like to use them? Let me know in the comments!
Leave a Reply