Easily Create WordPress Child-Themes and Transform Your Website

Updating a WordPress theme can often result in losing all of your customizations. That’s where child-themes come in! By creating a child-theme, you can make changes to your website’s design, functionality, and layout without losing any of your customizations during theme updates. This blog aims to provide easy-to-follow tutorials to help anyone, regardless of their experience with WordPress, create a child-theme and customize their website to their liking.

I literally followed this guide for the Midjourney-Blog WordPress theme. I made a child-theme within 5 minutes, tested it and it all works. Now when I update the main Midjourney-Blog theme, I can keep the special pages I made without compromising security or the WordPress Theme update.

Here are the steps to create a child template for your existing WordPress theme:

  1. Create a new folder in your WordPress theme directory. You can name this folder anything you like, but it’s a good practice to name it after your parent theme and add “-child” at the end. For example, if your parent theme is named “MyTheme,” name your child theme folder “MyTheme-child”.
  2. In your new child theme folder, create a new file called “style.css”. This file will contain the information about your child theme.
  3. Add the following information at the top of your new “style.css” file:
/*
Theme Name: MyTheme Child
Template: mytheme
*/

Replace “MyTheme Child” with the name of your child theme, and “mytheme” with the name of your parent theme.

  1. Create a new file in your child theme folder called “functions.php”. This file will contain the functions that you want to add or modify in your child theme.
  2. Add the following code at the top of your new “functions.php” file:
<?php
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
function my_theme_enqueue_styles() {
    wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
}
?>

This code will enqueue the parent theme’s stylesheet and make it available for use in your child theme.

  1. Copy any files you want to modify from your parent theme directory to your child theme directory. For example, if you want to modify the header of your parent theme, copy the “header.php” file from your parent theme directory to your child theme directory.
  2. Modify the files you copied as needed to make the changes you want to make.

Don’t forget to add your page

You will need to create a copy of the parent theme’s page.php file and add it to your child theme directory. This will allow you to modify the page template as needed without affecting the parent theme.

To create a child page template, follow these steps:

  1. In your child theme directory, create a new file and name it page.php.
  2. Copy the contents of the parent theme’s page.php file into your new child theme page.php file.
  3. Modify the page template as needed. You can add or remove any code, change the layout, or add new functionality to the template.
  4. Save the changes to your child theme page.php file.
Needed files for our WordPress Child-Theme
Needed files for our WordPress Child-Theme

Your child theme page.php file will now override the parent theme’s page.php file. When WordPress loads a page, it will use the child theme page.php file instead of the parent theme’s page.php file, allowing you to modify the page template without affecting the parent theme.

Note that you can also create other custom page templates for your child theme, such as full-width or sidebar templates, by creating new template files in your child theme directory and using the appropriate WordPress template tags to load them.

Add the template name in the page.php file so you can easily find it:

Make sure to add the WordPress Template Name
Make sure to add the WordPress Template Name
/*
Template Name: My Custom Page Template
*/

That’s it! Your child theme is now ready to use. Any changes you make to your child theme will be kept separate from the parent theme, so you won’t lose them when you update the parent theme in the future. To activate your child theme, go to the WordPress admin panel, navigate to Appearance > Themes, and select your child theme.

My video on YT with tips on creating WP Child themes

You might also like to read:

Share This Message