Davis Web Studio
How to Create a Child Theme in WordPress and Why It’s a Good Idea

How to Create a Child Theme in WordPress and Why It’s a Good Idea

Share this post:
[wd_hustle id="blog-posts" type="social_sharing"]

If you design sites in WordPress, then you’ve probably heard of child themes. But what are they and why are they a good idea? I’ll answer those questions and show you how to create your own child theme in WordPress.

In case you’re wondering, a WordPress child theme is exactly what it sounds like. It’s a theme that inherits the functionality of another theme, called the parent theme. You can create a child theme for any WordPress theme that you want to customize. The best part is that child themes are really easy to set up.

When don’t use a child theme and instead make changes directly to your WordPress theme, those changes will be overwritten any time you upgrade your theme.

The benefit of creating a WordPress child theme

The biggest benefit to starting out with a child theme even if you don’t think you need one right now is that if you change your mind later, switching to a child theme after you’ve already designed your site will cause you to lose any settings you’ve applied when designing your website. This a real pain, I don’t recommend putting yourself through it. I’ve been there/cursed that.

(If you’ve already designed your site and now you’re in a position where you need a child theme, go through all of your site settings and take screenshots. This includes fonts, colors, and WordPress Settings. Then reference those screenshots when re-applying your settings. I recommend making these changes on a copy of your site (staging site) first so your live website doesn’t break in full view of the internet.

Do you need to create a new WordPress child theme?

Before you bother creating your own custom WordPress child theme, check to see if you already have one. Many themes you can buy online have included a child theme in the folder you download when you purchase the theme.

Look in your download folder for a zipped folder named -child. If there’s one in there go ahead and install that. Go into Appearance > Themes > Upload. Upload the child theme’s zip folder and activate it. The parent needs to stay installed in order for this to work. The child theme references that parent theme and only overrides it selectively.

If you don’t have a child theme already, some of the most popular themes have a child theme generator or instructions for downloading a compatible child theme on their site.

Here are a few:

There’s one more easy option if you don’t feel comfortable creating the CSS and PHP files and adding the code for the child theme. The Generate Child Theme plugin will generate a child theme for you. Follow the steps on the plugin page to take this route.

Creating a WordPress child theme from scratch

If you’re looking to create a child theme though, I’m guessing you might have technical aptitude. (I believe in you.) Here’s how I, a WordPress Developer, create a child theme if I don’t have one already.

You can follow these steps right on your computer, you don’t need access to your web server to do this. Use the download folder from your parent theme for reference.

  1. Create a new folder and name it the same as your parent theme adding a -child on the end.
  2. Create a new file in your folder and name it style.css. This is technically the only required file.
  3. Edit that file with a text editor (something like Notepad, Atom, or Visual Studio)
  4. Add this to the top of the style.css file
  5. Replace the Theme Name with your unique child theme name. After Template:, add the name of your parent theme folder.
  6. Create a new file in the folder called functions.php
  7. Add this to the functions.php file using your text editor.
<?php
function my_theme_enqueue_styles() {
wp_enqueue_style('parent-style', get_template_directory_uri().'/style.css');
}
add_action('wp_enqueue_scripts', 'my_theme_enqueue_styles');
  1. Themes > Upload.
  2. Activate the theme.

That’s all there is to it! Your child theme is now active and you can start making customizations. Keep in mind that if you make changes to the style.css file, those changes will be applied to your website. Copying templates from the parent theme into the child will allow you to edit those templates in the child theme without affecting your ability to upgrade your parent theme.

Now that you know how to create a child theme, what should you do?

Here are some ideas:

  • Create a custom header or footer
  • Change the colors of your site
  • Add new fonts
  • Edit the layout of your pages
  • Create a custom post or page template
  • Add your own CSS and JS files to the child theme folder for more advanced customization.
Share this post:
[wd_hustle id="blog-posts" type="social_sharing"]