What is a child theme and when should you use it?

Category(ies): Wordpress
Published on 30.10.2022
Web Designer

What you can expect in this article:

In this article, I'll tell you everything you need to know about child themes in WordPress. You'll find out what it's all about, why you should use it in most cases and how you can create a child theme in just a few minutes - manually and with a generator.
Christian Strasser Webdesigner

About the author:

Christian is a web designer & developer with over 8 years of experience in WordPress and web development. He develops conversion-optimized websites & online stores that perfectly combine design and function to make companies successful online. In addition to his work, he travels around the world and is inspired by new impressions.

What is a child theme anyway?

To do this, I will briefly take a bird's eye view of a WordPress site. WordPress is a content management system that can be used to create online presences of all kinds. Although WordPress itself has all the tools you need to edit a website, it doesn't offer much in the way of functionality or design options.

This is exactly what a theme does. A theme gives your WordPress website almost infinite design and functionality options, depending on your choice.

A child theme is, as the name suggests, a Child of this parent theme and inherits all functionality from this and Enables customizations and extensions to the parent theme (= main theme).

Why do I need a child theme?

So if you need to change or add something in a WordPress file, such as style.css, wp-config.php or functions.php, you can or, as you will see in a moment, should do this via your child theme. 

The problem is that with (major) theme updates it can happen that the update deletes or overwrites all manual changes. Then all your changes are gone. 

Main advantages of a child theme

Lossless updates and security. As all changes were made in the child theme, there is no risk that they will be lost with the next update.

Clear structure and quick understanding. Because all adjustments are made in the child theme, it is very easy to see what has been adjusted or extended in the theme. If all changes are made in the main theme, it is extremely time-consuming (many different files!) to find out what has been worked on everywhere.

How to create and use a child theme in under 5 minutes

A child theme can be created either manually or with a generator.

Manual creation

It is relatively easy to create a child theme yourself. Create a new folder for the child theme in wp-content/themes and create a style.css and functions.php with certain specifications. You can then activate the child theme in WordPress.

In the style.css you must insert the following code with your own details:

/*
Theme name: Name of your child theme
Description: Description of your child
Themes Author: Your name
Author URI: URL of your website
Template: Name of the parent theme
Folders Version: 1.0.0
*/

In the functions.php we need the following code (you don't need to make any changes here):

<?php
function enqueue_child_styles() {
wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() .'/style.css' , array('parent-style'));
}
add_action( 'wp_enqueue_scripts', 'enqueue_child_styles' );

Creation with a generator

Another charming option is the creation thanks to a child theme generator. For example the one from Bloggerpilot

The creation process is self-explanatory: select parent theme, enter child theme name & desired optional details, upload photo, enter e-mail address and click on download.

The child theme is then available in ZIP format in the download folder. This must now be installed in WordPress under Design - Theme uploaded and activated become.

Correct use of a child theme

Now, of course, it is important that you make your changes in the child theme and not in the parent theme (this also includes the CSS in the Divi Theme options). Sounds banal, but I see it quite often.

That means every style change or function extension you must from now on in the style.css resp. the functions.php of your child theme make.

Conclusion

  • You should use a child theme as soon as you make changes to the theme.
  • A child theme ensures security for updates and a clear (change) structure
  • The creation is super easy and done in a few minutes

Comments

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

en_USEN
Christian Strasser

Christian Strasser

On working days I reply within a few hours.

On working days I usually reply within a few hours.

Christian Strasser
Hi 👋 
please leave me a message.

I will get back to you as soon as possible.

Best regards,
Christian
Whatsapp

Data protection consent