What is a Child Theme in WordPress and How to Create One?
Introduction
A Child Theme is a subordinate WordPress theme that is based on an existing Parent Theme. It inherits the design and functions of the parent theme but allows you to make customizations without modifying the original files. This way, your changes remain intact even after theme updates.
When Should You Use a WordPress Child Theme?
- If you want to customize your theme without editing the parent theme directly.
- If you want to update the parent theme without losing your changes.
- If you don’t want to start a completely new theme development but want to build upon an existing theme.
How Does a WordPress Child Theme Work?
A child theme consists of at least two files:
style.css
– with a header comment that tells WordPress which parent theme is used.functions.php
– loads the parent theme’s stylesheets and can add its own functions.
WordPress loads the parent theme first and overrides only the parts defined in the child theme.
Creating a Child Theme – Step by Step
- Create folder: Create a new folder in the
wp-content/themes/
directory, e.g.,twentytwenty-child
. - Create style.css: Create a file named
style.css
in the new folder with the following content:
/*
Theme Name: Twenty Twenty Child
Theme URI: https://www.curiaweb.ch
Description: Child theme for Twenty Twenty
Author: Curiaweb GmbH
Author URI: https://www.curiaweb.ch
Template: twentytwenty
Version: 1.0
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
*/
- Create functions.php: Create a file named
functions.php
with the following content to load the parent stylesheet:
<?php
add_action( 'wp_enqueue_scripts', 'curiaweb_enqueue_child_styles' );
function curiaweb_enqueue_child_styles() {
$parenthandle = 'twentytwenty-style'; // Name of the parent stylesheet
wp_enqueue_style( $parenthandle, get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'child-style', get_stylesheet_uri(), array( $parenthandle ), wp_get_theme()->get('Version') );
}
- Activate Child Theme: In the WordPress admin under Appearance > Themes, select and activate the new child theme.
What Now?
Your child theme is active. You can now:
- Add your own CSS rules in
style.css
. - Add your own PHP functions in
functions.php
. - Copy and customize template files from the parent theme.
Recommendation from Curiaweb
Test all changes first in a safe staging environment. At Curiaweb, you can create a WordPress staging site with one click to safely test your changes before going live.
FAQ
What happens if I don’t use a child theme?
Changes to the parent theme will be lost during updates.
Can I use plugins instead of child themes?
For pure functionality extensions, plugins are usually the better choice.
Do I need programming skills?
Basic knowledge of CSS and PHP helps but is not mandatory for small adjustments.
Questions? Our Curiaweb Support is happy to assist you!