BLACK FRIDAY!Up to 50% OFF
See deals
WP-Script Logo

How to create a WordPress child theme

February 14, 2023Updated 17 min readThemes

If you're looking to customize your WordPress website, then creating a child theme is a must-do. Child themes allow you to make changes to your website's design and functionality without affecting the parent theme, making it easier to update your website in the future.

In this article, we'll walk you through the process of creating a child theme step-by-step. We'll cover everything from setting up the child theme directory to customizing your stylesheet and adding new functions to your theme.

We'll also talk about some common issues that you may encounter and how to troubleshoot them. This guide is for beginners and for seasoned WordPress pros. It has everything you need to create your very own child theme. Let's get started!

Why and When Should I Use a Child Theme?

Benefits of using a child theme

Safe Customizations

One of the biggest benefits of using a child theme is that it keeps your customizations safe. With a child theme, you can make all the changes you want without altering the original code of the parent theme. This means that even if you update the parent theme, your customizations will remain intact.

Easy to Customize

Child themes make it easy to customize your site without having to touch any complicated code. You can use the child theme to make changes to the look and feel of your site, add new functionality, and more.

Speed Up Development Time

If you're a web developer, using a child theme can save you a lot of time. You can use a pre-existing parent theme as a starting point for your project and then customize it as needed. This can save you time and effort compared to starting from scratch.

Keeps Your Site Up-to-Date

Child themes allow you to keep your site up-to-date with the latest version of the parent theme. You can update the parent theme without worrying about losing your customizations.

Easy to Share Customizations

If you're working on a project with multiple people, using a child theme makes it easy to share customizations. You can create a child theme and share it with your team, allowing them to make changes without affecting the original code of the parent theme.

So, if you're looking to make customizations to your WordPress site, using a child theme is a great option. Not only does it make customizing your site easy and safe, but it also offers many other benefits that can save you time and effort.

When to use a child theme in WordPress

Here are some situations where a child theme is ideal:

  • When you want to make changes to your website's appearance, such as modifying colors, fonts, or layouts, but don't want to risk breaking the parent theme's code.
  • When you want to add custom functionality to your website without modifying the parent theme's code. This is especially useful if you plan on updating the parent theme in the future, as the changes you make will not be lost.
  • When you're working with a premium theme that you don't have the source code.
  • When you're using a theme framework that is updated frequently

How to Create a WordPress Child Theme

Creating the child theme directory

When it comes to creating a WordPress child theme, the first step is to create the child theme directory. This is where all of your child theme's files will reside. There are a few different ways to create the directory, but one of the most straightforward is to simply create a new folder on your computer and then upload it to your WordPress site.

To create the folder, simply open your file explorer, navigate to your preferred location, right-click, and select "New Folder". Name the folder with your desired child theme name. After that, you'll need to upload the folder to your WordPress site. This can be done either via FTP or by accessing your site's file manager through your hosting control panel.

Once the folder is uploaded, you'll need to create the required files for your child theme. The most basic of these is the stylesheet, which we'll discuss in more detail in the next section. But for now, it's important to note that having the child theme directory set up is an important first step in creating your child theme.

The folder of the RetroTube child theme in wp-content/themes: functions.php, readme.txt, screenshot.png and style.css.The folder of the RetroTube child theme in wp-content/themes: functions.php, readme.txt, screenshot.png and style.css.

Creating a stylesheet

The stylesheet acts as the foundation for your child theme, and it's what allows you to make customizations to the look and feel of your site.

To create a stylesheet, you'll need to open up your preferred text editor and create a new file. Give the file a name such as "style.css" and save it in your child theme directory.

Next, you'll need to add the following code to the top of the stylesheet:

/*
Theme Name: [Your Child Theme Name]
Theme URI: [Your Child Theme URL]
Description: [A brief description of your child theme]
Author: [Your Name]
Author URI: [Your Website URL]
Template: [The folder name of the parent theme you are using]
Version: 1.0
*/

This code provides important information about your child theme to WordPress, such as the theme name, author, and parent theme.

Once you've added this information, you're ready to start customizing your child theme's stylesheet. Font styles, background colors or other design elements: everything you do in the stylesheet will be specific to your child theme and won't affect the parent theme in any way.

For your information, you don't have to fill in all these fields. Only 2 are required:

  1. "Theme Name"
  2. "Template"

Our ready-made child themes (see the end of this article) keep the line Author: WP-Script. Keep it as it is, as the note in their style.css asks.

Here is a concrete example with our flagship theme: RetroTube Adult WordPress Theme

/*
Theme Name: RetroTube Child
Author: WP-Script
Template: retrotube
*/

The style.css of our ready-made RetroTube child theme, with Template: retrotube and the Author: WP-Script line.The style.css of our ready-made RetroTube child theme, with Template: retrotube and the Author: WP-Script line.

Loading the style of the parent theme

Your child theme must also load the style of the parent theme. To do this, create a functions.php file in your child theme directory and add the following code. Let's continue with the example of RetroTube (this is the code of our ready-made child themes):

<?php
add_action( 'wp_enqueue_scripts', 'wpst_child_enqueue_styles' );
function wpst_child_enqueue_styles() {
	$theme = wp_get_theme();
	// Load the parent theme stylesheet.
	wp_enqueue_style( 'wpst_style', get_template_directory_uri() . '/style.css', array(), $theme->parent()->get( 'Version' ) );
	// Load the child theme stylesheet after the parent one.
	wp_enqueue_style( 'child-style', get_stylesheet_uri(), array( 'wpst_style' ), $theme->get( 'Version' ) );
}

The functions.php of our ready-made RetroTube child theme: it loads the parent theme style first, then the child theme style.The functions.php of our ready-made RetroTube child theme: it loads the parent theme style first, then the child theme style.

Older tutorials use @import in style.css. Do not use it: it makes your pages load slower. WordPress recommends loading the parent style from functions.php, as above.

It's important to note that the Template line of your style.css must match the folder name of your parent theme. Once you've saved these files, your child theme will inherit the styles of the parent theme.

By loading the styles of the parent theme, you'll have the ability to make changes to your website's design and layout without affecting the parent theme. Any changes you make to your child theme will take precedence over the parent theme's styles, allowing you to easily customize your website to fit your needs.

Activating the WordPress child theme

Activating a WordPress child theme is a simple process that involves just a few steps. Here's how you can do it:

  1. Log into your WordPress dashboard and navigate to the "Appearance" section.
  2. Find the "Themes" section and click on it.
  3. Locate the child theme you just created and click the "Activate" button.

Appearance > Themes with RetroTube Child Theme active, next to its parent theme RetroTube.Appearance > Themes with RetroTube Child Theme active, next to its parent theme RetroTube.

That's it! You've successfully activated your child theme and are now using it to customize your WordPress site.

How to Use a WordPress Child Theme

Adapting the code of a page template to your needs

Adapting the code of a page template to your needs is a powerful way to customize your WordPress website. This is where a child theme really shines, because it allows you to make changes to your website's design and functionality without touching the parent theme's code. This means that you can safely experiment with your website's design, knowing that your changes won't be lost if the parent theme is updated.

Here are some things to keep in mind when adapting the code of a page template:

  1. Make a backup of your website before you start making changes.
  2. Use a child theme to avoid affecting the parent theme's code.
  3. Look for the specific template file that you want to modify and copy it from the parent theme to your child theme directory.
  4. Make your changes to the copied template file in your child theme directory.
  5. Preview your changes on your website to see if everything looks and works as expected.

It's important to note that adapting the code of a page template is an advanced customization and requires a good understanding of HTML, CSS, and PHP. If you're not comfortable with these technologies, it's best to seek help from a professional developer.

Customizing the style sheet

Customizing the stylesheet of your WordPress child theme is an important step to give your website a unique look and feel. Here are a few things to keep in mind when customizing the stylesheet:

  • Use the style.css file in your child theme directory to make your customizations.
  • You can add new styles or overwrite existing styles in the parent theme by specifying the styles with higher specificity.
  • You can use CSS comments to indicate your custom styles, making it easier to identify and modify them in the future.
  • Use the inspector in your web browser's developer tools to identify the specific styles you want to change, and then make the changes in your child theme's stylesheet.

By following these steps, you can easily make customizations to the stylesheet of your WordPress child theme and give your website a unique look.

Adding new functions to your theme

If you want to add new functions to your WordPress child theme, it's best to use the functions.php file. This file is located in the child theme directory and is used to add custom functionality to your theme. Here's how you can add a new function to your child theme:

  1. Create a functions.php file in the child theme directory if it doesn't already exist.
  2. Open the file in a text editor.
  3. Add the following code to the file:
<?php
function your_function_name() {
// Your code here
}
add_action('init', 'your_function_name');

In this example, you can replace your_function_name with the name of the function you want to add. The code inside the function will be executed whenever the init action is triggered in WordPress.

This is just one example of how you can add a new function to your child theme. The possibilities are endless and you can add as many functions as you like to customize your theme even further.

Other Options to Create a WordPress Child Theme

Checking if your theme developer offers a pre-made child theme

One of the first things you should do before creating a child theme is to check if the theme developer offers a pre-made child theme.

This can save you a lot of time and effort, as the child theme will already include all the necessary templates and styles for you to start customizing. Some theme developers even offer detailed documentation and tutorials on how to use their child themes, making it a great option for those who are new to WordPress.

Using a WordPress child theme plugin

When it comes to customizing your WordPress theme, a child theme plugin can be a convenient option for those who aren't comfortable with writing code.

There are several child theme plugins available in the WordPress plugin repository, including Child Theme Configurator. Simply install the plugin of your choice, activate it, and follow the steps to create a child theme.

The child theme plugin will take care of creating the necessary files and directories, importing the styles of the parent theme, and even providing a user-friendly interface for customizing your theme. No need to worry about the technical details, just sit back and enjoy the flexibility and ease of use of a child theme!

Using a browser-based WordPress child theme generator

If you're looking for a more hands-off approach to creating a WordPress child theme, you may want to consider using a browser-based WordPress child theme generator. This type of tool is typically web-based, meaning you don't need to install any software on your computer. Simply visit the website, follow the instructions, and your child theme will be generated for you.

The process is simple: you provide the details of your parent theme, including its name, stylesheet, and template files, and the generator will take care of the rest. You can even preview your child theme before downloading it to make sure everything looks as it should.

There are several browser-based WordPress child theme generators available, each with its own set of features and capabilities. Some are free, while others require a fee. Before you start using one, take the time to read reviews and compare the options available to determine which is best for your needs.

Once your child theme has been generated, you can further customize it to meet your specific needs, just like you would with any other WordPress child theme. And because it's all done through a web browser, there's no need to install any additional software, which can be a big time-saver for those who aren't comfortable with coding or who simply prefer a more streamlined approach.

WordPress Child Theme Not Working

Double-checking your functions.php file

If you've created a child theme and it's not working as expected, don't worry! One of the most common issues is a mistake in the functions.php file. Here are some steps to help you double-check and fix the problem.

  • Firstly, do not load the parent theme's functions.php yourself. WordPress loads your child theme's functions.php first, then the parent's, automatically (theme handbook). If you add a require_once of the parent file, the same functions are loaded twice and your site can break.
  • Secondly, check for any typos or syntax errors in your code. Make sure your functions are properly defined and closed. Also, ensure that you've used the correct hook for each function you're trying to modify.
  • Finally, try deactivating and reactivating your child theme. This can sometimes help resolve any issues that may have been caused by a plugin or a recent WordPress update.

If you've checked all these things and your child theme is still not working, you might want to consult the theme developer or a WordPress expert for further help.

Ensuring you named the sheet “style.css”

If your WordPress child theme is not working, it might be due to an error in your style sheet. One common mistake is naming it incorrectly. Ensure that you have named your sheet "style.css" as this is what WordPress looks for by default. This may seem like a small detail, but it can have a big impact on the functioning of your child theme. Make sure you double-check the name of your sheet and see if that fixes the issue.

Making sure you used the correct Template name in style.css

It's important to make sure that you've used the correct Template name in your style.css file. The Template value must be the folder name of the parent theme, in lowercase. For RetroTube, it is retrotube. If the Template name is incorrect, WordPress won't recognize your child theme as a separate entity and won't apply the styles and customizations you've made.

Clearing your cache

Sometimes, after making changes to your WordPress child theme, it might not seem to be working as expected. One common issue is caching. When you view your website, your browser might store a cached version of the pages you've visited. To ensure you're seeing the latest changes, it's always a good idea to clear your cache. Here's how to do it:

  • In your browser, click on the three dots (or dots and bars) in the upper right corner
  • Find the "History" or "Privacy" option and click on it
  • Look for "Clear Browsing Data" or "Clear Cache" and click on it
  • In the pop-up, select "Cached images and files" and hit "Clear Data"

It's that simple! Clearing your cache ensures that you're seeing the latest version of your website, including any changes you've made to your child theme.

Adding !important to your CSS code

It's a useful technique to override any conflicting styles from your parent theme and ensure that your custom styles are applied correctly.

Here's how you can use !important in your CSS code: Simply add "!important" after the value of your CSS property. For example, if you want to change the background color of an element, you can write:

background-color: blue !important;

Keep in mind that using !important excessively can make your CSS code messy and hard to maintain. So, it's best to use it sparingly and only as a last resort when all other methods have failed.

Contacting your theme's support

If you've tried all of these solutions and your child theme still isn't working, it may be time to reach out to your theme's support team. They'll be able to help you diagnose and fix any issues you're experiencing. Just make sure you have all relevant information handy, such as your theme version and any error messages you've received.

Child Themes for WP-Script Themes

If you're using a WP-Script theme, you can create your own child theme by following the methods discussed above.

As it can be a bit overwhelming, we have already created a zip file for each theme with the backbone code you need to start.

Child Theme for FamousTube

FamousTube Child ThemeFamousTube Child Theme

FamousTube Child Theme

Download famoustube-child.zip

Child Theme for KingTube

KingTube Child ThemeKingTube Child Theme

KingTube Child Theme

Download kingtube-child.zip

Child Theme for KolorTube

KolorTube Child ThemeKolorTube Child Theme

KolorTube Child Theme

Download kolortube-child.zip

Child Theme for RetroTube

RetroTube Child ThemeRetroTube Child Theme

RetroTube Child Theme

Download retrotube-child.zip

Child Theme for UltimaTube

UltimaTube Child ThemeUltimaTube Child Theme

UltimaTube Child Theme

Download ultimatube-child.zip

Child Theme for VTube

VTube Child ThemeVTube Child Theme

VTube Child Theme

Download vtube-child.zip

Final thoughts on WordPress child themes

A WordPress child theme is a great tool for customizing your website. It provides a safe and efficient way to make changes to your site's design and functionality, without risking the loss of your customizations during future updates. Child themes also allow you to extend and build upon the existing features of a parent theme, without making changes directly to the parent theme code.

In this article, we've explored the basics of child themes in WordPress, including how to create a child theme, load the styles of a parent theme, and customize your child theme's code and styles. We've also looked at different methods for creating a child theme, including using a plugin or a browser-based generator.

Finally, we've discussed some common issues that may arise when using a child theme, and how to troubleshoot them. For beginners and experienced WordPress users alike, a child theme is a valuable tool for customizing your website.

So, if you're ready to take your WordPress website to the next level, consider using a child theme. For small tweaks or large changes, a child theme can help you achieve your goals with ease and confidence.

Written by

Cédric, Co-founder of WP-Script

Cédric is a co-founder of WP-Script, made by PandaCorp since 2016. He builds the WP-Script themes and plugins with the team, and writes these guides from what our support team sees in the tickets every week.