Use the coupon code WORDPRESS and save 30% OFF! Buy Now

Knowledge base

Creating a child theme

People love to customize their themes, we daily get dozens of requests for help with all sorts of creative changes our users want to apply on their freshly bought themes. However, when the time comes to update the modified theme to a newer version, things get tricky due to the risk of either losing your changes or having to reapply them one by one. Users rarely create child themes, when asked if they have done so, they reply either that they do not know what a child theme is or that they thought it was difficult to create one an skipped it. Hopefully, this guide will correct both issues.

What is a child theme

According to the WordPress Codex:

A child theme is a theme that inherits the functionality of another theme, called the parent theme. Child themes allow you to modify, or add to the functionality of that parent theme. A child theme is the best, safest, and easiest way to modify an existing theme, whether you want to make a few tiny changes or extensive changes. Instead of modifying the theme files directly, you can create a child theme and override within.

Essentially a child theme is a supplementary theme, it is not a standalone theme, it requires the presence of its parent in order to work. It inherits all functionality found on the parent theme and allows the user to easily extend it.

Why use a child theme

The major advantage is that it makes updating very easy and very fast. Let’s say that you pick a theme you like and you come up with a couple of changes you’d like to see made on each listing template and a few more for your widgets, once done, you realize that there is a new version of your theme available, your options now are, either to keep using an outdated version, which of course we all know is not optimal, or install the new version and reapply all changes one by one, because any change made in a theme’s file, won’t transfer through updates. If you use a child theme, on the other hand, all the edited files are in the child theme’s folder, so updating the parent won’t affect them at all.

Another advantage is that a child theme gives you the ability to experiment with your changes without worrying what happens if you break something, if you do, you can easily switch to the parent theme and your site will work just fine, you now have all the time you need to find out what went wrong and revert it, without causing significant downtime.

How to create a child theme

We offer child themes for all of our themes, just navigate to the downloads section and grab the ready made child theme for yours.

Creating a child theme is very easy, all you need to create is a folder and a file.

Use Filezilla, or any other FTP client, to log into your server and navigate to the /wp-content/themes/ folder of your WordPress installation. You will see a few folders, each one represents a theme. In our example we have only Aegean v1.9 installed.

guide-1-parent

proceed by creating a new folder called ‘aegean-child’ as demonstrated below

guide-2-child

next, enter the ‘aegean-child’ folder and inside create a file called ‘style.css’

guide-3-child-style

now edit the style.css file with your favorite text editor ( for example, you can use Notepad++ for Windows, Textedit for Mac and Leafpad for linux) and paste these in

/*
Theme Name: Aegean Resort Child theme
Theme URI: http://yoursite.com/aegean-child
Description: A child theme for Aegean Resort
Author: Me
Author URI: http://yoursite.com
Template: wp_aegean5-v1.9
Version: 1
*/

@import url("../wp_aegean5-v1.9/style.css");
/* Place your custom styles below this line
-------------------------------------------------------------- */

this will give your child theme a name and connect its stylesheet with the one of the parent theme.

TIP: notice that the template name and the @import URL match exactly the folder name of the parent theme, this piece of information will be very useful when we need to update the theme.

That’s it. Your child theme is done, you can go to Appearance → themes in your WordPress dashboard and activate the ‘Aegean Resort Child Theme’.

You are ready to start customizing your theme. You can paste any styles below the indicated line in the style.css file, or in our custom CSS box in the CSSIgniter Settings panel.

If you have built a function you want to incorporate to your child theme all you need to do is create a file called ‘functions.php’ with this content:


<?php

//Your new functions below this line

and paste it in where indicated, no need to mess with the parent’s functions file.  The same goes if you want to modify an existing template, you copy the template file from the parent theme to the child and edit away. Finally, you can also create new templates, for example, you need to create a custom template for the ‘villas’ room category, in your child theme’s folder, create a file called taxonomy-room_category-villas.php edit it and build your template any way you wish to.

There is an update for my parent theme, what do I do now?

First, you download and install the updated version, as usual, in our example, this will be Aegean v2.0

Use Filezilla again to log into the /wp-content/themes/ folder of your installation, you will see something similar to this

guide-4-update

enter your child theme’s folder, in this case, ‘aegean-child’ and edit the style.css file. You will need to modify the ‘Template:’ name and the ‘@import’ url to match the folder name of the updated version, the end result should look like this

/*
Theme Name: Aegean Resort Child theme
Theme URI: http://yoursite.com/aegean-child
Description: A child theme for Aegean Resort
Author: Me
Author URI: http://yoursite.com
Template: wp_aegean5-v2.0
Version: 1
*/

@import url("../wp_aegean5-v2.0/style.css");
/* Place your custom styles below this line
-------------------------------------------------------------- */

Done! You have successfully updated your theme to its latest version without having to worry what will happen with all those changes you made to the template files.

Conclusion

As demonstrated above, creating a child theme requires at most five minutes to create and apart from its major advantage, making the updating procedure of a modified theme a breeze will also help you to understand more about WordPress theme development by allowing you to experiment with template options, without the fear of breaking anything. After reading this article, there is no excuse for not creating a child theme if you want to customize your theme, go create one and start creating!

Get access to all WordPress themes & plugins

24/7 Support Included. Join 115,000+ satisfied customers.

Pricing & Sign Up

30-day money-back guarantee. Not satisfied? Your money back, no questions asked.

Back to top