How to make a WordPress child theme in 2 minutes

In the following article we will show you how to create a WordPress child theme manually, basically in a couple of minutes.

Why do you need a WordPress child-theme?

When WordPress automatically updates itself on your server (or you update your themes via the WordPress admin interface manually) it will download the new files and simply overwrite the old ones. No back up. That’s right. All your changes, your tweaks that you have done will be gone after the update.

And that’s when a child theme comes in. By creating a child theme folder on the server and copying a few files in there, WordPress will check this folder before the update and only overwrite the files in the parent theme, not in the child theme.

Let’s see how to create a child theme withouth any plugin.

Yes, you could probobly find a plugin for this. There is plugin for everything nowadays. But why slowing down your server’s speed even more, when you already running a bunch of plugins already? The less plugin is the better.
Let’s do this manually. Not so difficult as it sounds. Create a folder in your Theme folder and call it whatever you want (I call mine ‘Twentytwentyone-child’ the parent theme being ‘Twentytwentyone’). But it really does not matter, you can call it anything you want becouse after that you just need to activate this theme. So it can be named anything.

After you created the child theme folder you can put any files there that you have modified in WordPress and you can be sure these will not be overwritten by an upcoming update. These files can be php, css, javascript and even images. The WordPress update will not touch them.

In order for the WordPress child theme to work you need to put only two essential files there: a stylesheet and a php page. Let’s see what is in those 2 files.

The stylesheet (style.css) content:

Theme Name: Twenty Twenty One Child Theme
Description: A child theme of the Twenty Twenty One default WordPress theme
Author: Your name
Template: twentytwentyone Version: 1.0.0

The php page (function.php) must contain the following content:

// enqueue parent styles
function ns_enqueue_styles() {
wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
add_action( 'wp_enqueue_scripts', 'ns_enqueue_styles' );

Activate your child theme.

The last step is to activate your new child theme that you just created. You probably know how to do that. Go to WordPress admin and from the ‘Appearance/Themes’ menu activate the child theme.

Test your WordPress child theme.

You can make a quick test to see if the theme works. For example copy the footer.php from the parent theme to your newly created child theme. With a text editor make some changes in it. For instance remove the ‘Made by Worpress’ text :)
Save it and check your website. The text must be gone from the footer and when a new WordPress update comes around – it will stay that way.

Alternatively you can put an image in the child theme folder, called ‘screenshot.png’ to show that as a thumbnail for your theme in the Theme menu.