Skip to content

🌐 Leggi in Italiano

WordPress child theme example

Creating a child theme in WordPress is quick and simple. To create a child theme you need to follow a few simple rules to avoid running into problems.

Alessandro Manias Alessandro Manias Published on · Updated on · 3 min read
Cover image: WordPress child theme example

Contents

How do you create a child theme in WordPress?

Creating a child theme in WordPress is quick and simple. To create a child theme you need to follow a few simple rules to avoid running into problems.

I'll quickly explain what I did to create the child theme for this site: I decided to use the theme the WordPress team created last year, Twenty Nineteen.

You can find the theme's files in this folder of your WordPress installation:

/wp-content/themes/twentynineteen

First of all, create a new folder inside the themes folder:

/wp-content/themes/twentynineteen-child

The folder name doesn't matter, but by convention it follows the pattern parentthemename-child.
In fact I called the folder twentynineteen-child.

Next, create the style.css file.
This file is read by the WordPress core and used to retrieve basic information about the theme.

/*
Theme Name: Twenty Nineteen Child
Theme URI: https://wordpress.org/themes/twentynineteen/
Author: the WordPress team
Author URI: https://wordpress.org/
Description: Our 2019 default theme is designed to show off the power of the block editor. It features custom styles for all the default blocks, and is built so that what you see in the editor looks like what you'll see on your website. Twenty Nineteen is designed to be adaptable to a wide range of websites, whether you’re running a photo blog, launching a new business, or supporting a non-profit. Featuring ample whitespace and modern sans-serif headlines paired with classic serif body text, it's built to be beautiful on all screen sizes.
Requires at least: WordPress 4.9.6
Version: 1.4
License: GNU General Public License v2 or later
License URI: LICENSE
Text Domain: twentynineteen
Template: twentynineteen
*/

The important line is line 12, where you declare that the parent theme is the one in the twentynineteen folder.

You will also find the information above in the WordPress theme management screen.
If you want to dig deeper, here is the page about style.css in the WordPress developer documentation.

Another essential file for a WordPress theme is functions.php; again, you can learn more in the WordPress documentation.

<?php
/**
 * Functions for child theme.
 *
 * @package twentynineteen-child
 */

add_action( 'wp_enqueue_scripts', 'enqueue_parent_theme_style' );
/**
 * Enqueue the parent theme style.css
 */
function enqueue_parent_theme_style() {
	$theme = wp_get_theme();
	wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css', array(), $theme->get( 'Version' ) );
}

With these two files in place you have set up the basis of your child theme and can go on to edit and update your new child theme.

For example, I copied the header.php file from the parent theme to make some small changes inside the <head> tag.

What are the use cases for a child theme?

A child theme lets you customise a WordPress theme without compromising updates to the parent theme.
This is very important for keeping your WordPress installation secure.

If you want a very simple customisation example, read my article about customising the header.php file.

What exactly does that mean?

It means that once the child theme is created we can change and customise the way WordPress displays the site without losing the ability to update the parent theme from the WordPress dashboard.

Updating the parent theme?

WordPress is made of several parts: there is the core, which contains all the basic code that makes WordPress work.

Then there are themes and plugins.
Themes are the part of WordPress responsible for displaying the site's content.
By using a child theme you can keep the parent theme constantly up to date without losing, every time, the customisations you have added to your site.

What does a child theme consist of?

A child theme is a folder created inside the themes folder that, at a minimum, contains a style.css and a functions.php.

In this folder we will also create every file we want to override in, or add to, the parent theme.

© 2026 Wordpress e PHP. Statically generated with SvelteKit.