How to create a WordPress child theme (3 easy methods)
If you’re looking to create your own WordPress child theme, there are a few different ways to go about it. In this article, we’ll outline three easy methods that you can use. Whether you’re creating a new theme from scratch or using an existing theme as a starting point, these methods will help get you up and running in no time.
- What is a WordPress child theme and why do you need it?
- Method 1: Download WordPress child theme
- Method 2: Create a WordPress child theme using a plugin (removable plugin)
- Method 3: Create a WordPress child theme manually (using code, without plugin)
What is a WordPress child theme and why do you need it?
A WordPress child theme is a theme that inherits the functionality and styling of another theme, called the parent theme. Child themes are the recommended way to modify an existing theme.
The child theme can be used to add new features or to make styling changes. The installation process is the same as regular themes.
The advantage of using a child theme is that if you make changes to the parent theme, your changes will be preserved when the parent theme is updated. That is something you don’t need to happen because you will have to redo all the changes and modifications that you have done in your theme files. In simple words, you can use a child theme to customize your parent theme without having to edit the original files of your existing theme (parent theme).
Method 1: Download WordPress child theme
Wait, what? Yes, this is the easiest way. Will it work for all the themes? Absolutely, not. That’s why we have listed 2 other ways to create WordPress child theme.
Suppose, you are using a prevalent theme like GeneratePress, Astra, or Kdence themes. The chances of finding the original child theme are very high. You just have to Google ‘Your theme name’ download the child theme 😄
If you have purchased the theme from a place like ThemeForest, you can find the child theme from the zip file bundle downloaded from the website.
That was the easiest method. Let’s dive deeper to find other options.
Method 2: Create a WordPress child theme using a plugin (removable plugin)
There are multiple WordPress plugins that you can use to create a child theme. In this tutorial, I will use the most popular and the most reliable option. Child Theme Configurator is a fast and easy-to-use WordPress utility plugin that allows you to analyze any theme, create a child theme, and customize it beyond the options of the Customizer.
Installing the Child Theme Configurator plugin
1. Navigate to your WordPress dashboard and click on add new plugin
2. Search for the plugin “Child Theme Configurator.”. Install and activate the plugin
Plugin configurations
1. After the activation, you need to navigate to Tools » Child Themes in your WordPress dashboard.
2. On this page (you should be at the Parent/Child tab), the plugin will automatically select the active theme as your parent theme. If you want, you can change the theme as your requirement. In my case, I need to create a child theme for the default WordPress theme called Twenty Twenty-Two.
Now, go ahead and click on Analyze button.
3. After a couple of seconds, the plugin will run some tests to verify the compatibility of your theme. In most cases, you won’t be facing any issues.
Next, the plugin will ask for a name for your new child theme directory. The default will be the name of your theme – child. If you are planning to rebrand the theme, feel free to provide a custom name for the directory. But, I recommend you to keep the default settings.
4. Then, you can leave the default settings for the 5 and 6 sections.
5. In section 7, click on “Click to Edit Child Theme Attributes.” You will see several text fields to edit. Feel free to add some custom values if you need to do so.
6. In section 8, click on the checkbox to copy your theme settings, menus, and widget from your parent theme. This is an advantage over manual theme child theme creation.
You can ignore the warning basically, as I mentioned in the previous topic; if you are using a premium WordPress theme downloaded from a website like ThemeForest, they provide a child theme with the theme bundle most of the time.
7. Finally, click the button to create your new child theme. This will take about 5 to 15 seconds to prepare your theme.
Now, you can navigate to Appearance » Themes. Then, you will see your new child theme. Go ahead and activate the theme.
Suppose you are considering removing the Child Theme Configurator plugin. You can do it now. The plugin is not necessary from now. If you need it in the future, you can install the theme plugin later. The plugin will recognize your theme and child theme without any configurations.
Method 3: Create a WordPress child theme manually (using code, without plugin)
I should say that this method needs some coding experience, and you might need to have access to your file manager via your control panel, FTP, or a File Manager plugin. But, in this article, I’m not going to use those. Instead, I’m going to create the child theme files on my local computer.
Create a folder for your child theme
When naming the folder, make sure to use simple letters and use “-” for spaces—for example, my-child-theme. You can create the folder wherever you like on your computer.
In my case, I’m creating a child theme for the theme called Nave so that I will name my folder as nave-child.
Child theme folder structure
When we are creating a theme, WordPress expects two files (these two files are required).
- style.css
- functions.php
creating style.css stylesheet (CSS)
The style.css is a stylesheet (CSS) file required for every WordPress theme. It controls the website presentation (visual design and layout). Also, it contains the identity of your theme.
Let’s create the file. Create a text file and rename the file to style.css. Now, you can open the file using your text editor. For windows, the notepad will work fine. For Mac, you can use the TextEdit app.
Time to do some copy-paste action 😃 Paste the following CSS comment into your style.css file.
/*
Theme Name: Neve Child
Theme URI: https://example.org/your-theme/
Author: WP Authors
Template: neve
Version: 1.0
Description: Neve child theme
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: neve-child
*/
This is a CSS comment containing information about your new child theme. You can edit the following values to customize the theme with your information.
- Theme Name: Name of your child theme.
- Theme URI: The URL of a public web page where users can find more information about the theme. This is an optional property.
- Author: The name of the individual or organization who developed the theme. Feel free to use your name or your organization name.
- Template: The folder where the parent theme is stored. Use the folder name and not the theme name. Without this line, your theme won’t work as a child theme.
- Version: The version number
- Description: Descriptive text to help users understand what the theme does.
- License: The license, which must be GNU. [link] You can keep it as it is.
- License URI: The link to information on the license. You can keep it as it is.
- Text Domain: Use the text domain as the second parameter in any internationalization functions. Use your folder name
To find your parent theme folder name, you have to navigate to wp-content » themes directory using your file manager. I’m using the File Manager WordPress plugin in this example.
You can find more information about the style.css file on the WordPress Codex page.
Creating functions.php file
The functions.php file is where you add unique features to your WordPress theme. In our case, we can extend the functionalities of our parent theme.
Create a new file (in the same directory) called functions.php and open the file using your text editor.
Next, you have to import/inherit your parent theme’s styling files (CSS files). This is the only requirement in our functions.php file for now.
<?php
// Inherit parent stylings
add_action( 'wp_enqueue_scripts', 'wpauthors_enqueue_parent_styles' );
function wpauthors_enqueue_parent_styles() {
wp_enqueue_style( 'wpa-parent-style', get_template_directory_uri().'/style.css' );
}
One more thing, you can add a screenshot to your theme folder. It will appear in your WordPress dashboard Appearance > Theme section. This is optional, and no one will see this screenshot without visiting the above location. Simply, rename your image to screenshot.png
Need WordPress expert support?
Uploading your new child theme
Now, you should upload your theme to your WordPress website. First, you should compress your child theme folder into a zip file.
That’s it! Now you can go to your WordPress dashboard Appearance » Theme and click on Add New. Then, you will see a button called Upload theme. Go ahead and upload your zip file and activate the theme.
Conclustion
In conclusion, creating a WordPress child theme is an easy way to make changes to your website without affecting the original theme files. This can be helpful if you want to make small tweaks or if you need to update the original theme and don’t want to lose your changes. By following these simple steps, you can create a child theme in minutes.