How to create a WordPress child theme

Found a WordPress theme that you really like but want to customize its look a bit? You can easily do this by writing custom code in your theme’s CSS stylesheet. However, these changes can easily get lost when you update the theme.

To avoid this, you can create a child theme, allowing you to do as much customization as you want without running the risk of losing those changes when updating the parent theme.

We’ll walk you through every step of the way. First, let’s clear up the lingo a bit.


What exactly is a child theme?

A child theme is a fully functional WordPress theme that inherits its functions and properties from another theme, its parent theme. When you create a child theme, you can use all the features of the parent theme without losing those features every time the parent theme receives an update.

You will need three basic components to create a child theme, and these will be covered in detail when we explain how to create a child theme manually.

First, however, we will quickly see how to make a child theme using free child theme generators and using a plugin.

Ready? Let’s get into it!

1. How to create a child theme using a child theme generator

This is probably the easiest and most straightforward method of all. All you need to do is navigate to a child theme generator website, enter a name for your child theme, and that’s it.

VIDEO OF THE DAY MAKEUSE

Two of the most popular child theme generators are Astra Child Theme Generator and Child Theme Generator, which creates child themes for the popular Astra theme.


Screenshot-of-Astra-Child-Theme-Generator

Astra theme is a popular, light and fast WordPress theme that is suitable for building any kind of website. It’s also one of the best free WordPress themes of 2021, so it’s a good choice for building your website. To use Astra Child Theme Generator, you must first install the Astra theme.

To then create your new child theme, just log into Astra Child Theme Generator, enter the name you want for your new child theme, click produce, and that’s all!


Your new child theme will automatically download as a zip folder. Install and activate it just like you would any other theme.

2. How to create a child theme using a plugin

This method is almost as easy as using an online child theme generator. There are many child theme builder plugins out there, but we recommend using one of the most popular options – the child theme configurator.


Screenshot of the child theme configurator interface

To get started, install and activate the plugin from the WordPress repository. In the left panel, hover over Tools, then click Children’s Themes.

To create your child theme, check CREATE a new child theme, then scroll down and select the parent theme. Click on Analyze and wait for the results. If all of your theme files are in order, then you will see additional options on the screen. You can ignore most of them or make changes as needed.



Screenshot showing the interface of the child theme configurator

To bring your kid’s theme to life, just click the button Create a new child theme button at the bottom of the screen, and that’s it.

Navigate to Appearance> Themes, and your new child theme will be visible and ready to be activated.

Using a child theme generator or a child theme generator plugin are two great solutions that are easy to implement and do not require advanced technical skills. If you want to put yourself under the hood and take a more active role in creating your new child theme, the following method is for you.

3. How to manually create a child theme

Creating a child theme manually is much more interesting than either of the previous two methods, but it’s still relatively easy to do.

You will need three basic components: a theme file for your child theme, a style.css stylesheet and a functions.php to file.

1. Create a theme file

You can do this in cPanel or using FTP. We recommend using cPanel if your hosting service provides it. To connect to cPanel> File Manager> Files> Public_html> wp-content> themes.


Screenshot showing the WordPress theme folder in cPanel

Click on the + Folder in the top menu to create a new folder. You must name it after the name of the parent theme, adding “-child” at the end. If you are using the Twenty Twenty-One theme, for example, it will look like: “twentytwentyone-child”.

2. Create a Style.css file

Style.css is the default WordPress naming convention for CSS stylesheets. This is where all the CSS for your child theme will go, but you can wait to create the CSS until you have fully configured your child theme.

To create a style.css file, just click on the + File option in the top menu. The stylesheet should go to the new theme folder you just created. In the new file, paste the following comment:

/*
Theme Name: Twenty Twenty One Child
Theme URI: http://example.com/twenty-twenty-one-child/
Description: Twenty Twenty One Child Theme
Author: Jane Doe
Author URI: http://example.com
Template: twentytwentyone
Version: 1.0.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Tags: light, dark, two-columns, right-sidebar, responsive-layout, accessibility-ready
Text Domain: twentytwentyonechild
*/

This is a comment and will not be executed at run time, but without it your CSS stylesheet file will not work. Save the file as style.css.

3. Create a Functions.php file

Just like you added a new file and called it style.css, add a new file and name it functions.php. Paste the code below:


add_action( 'wp_enqueue_scripts', 'enqueue_parent_styles' );

function enqueue_parent_styles() {

wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );

}

?>

That’s it! You now have all three components required for your child theme to work. To finalize it, go back to your WordPress backend and activate the theme as you would any other theme.

Getting started with WordPress child themes

Child themes are a useful way to make changes to your WordPress theme without having to worry about parent theme updates. In this article, we’ve shown you three different and easy-to-use methods of creating a child theme. If all you are looking for is to create custom designs for your web pages, an effective alternative is to use a WordPress page builder.


awesome-uses-raspi
26 awesome uses for a Raspberry Pi

Which Raspberry Pi project should you start with? Here’s our roundup of the best Raspberry Pi uses and projects!

Read more


About the Author

Comments are closed.