How to Create a WordPress Child Theme in 5 Minutes

How to Create a WordPress Child Theme in 5 Minutes

Creating a WordPress child theme seems a task more suited for a web developer. However, creating a child theme is very easy and does not require programming knowledge. In fact, you can easily create a child theme within five minutes. Here, we will not go into the detail of how everything works with a child theme, but simply describe the process of creating a WordPress child theme as quickly as possible.

How to Create a WordPress Child Theme in 5 Minutes

Creating a WordPress child theme is necessary in case you want to change the styles or functionality of the WordPress theme. If you do not create a child theme and directly change styles of the theme, you will lose all changes when the theme updates.

  1. The first requirement is having a parent theme. A child theme cannot work without a parent theme. Select a parent theme that is suitable for customizations.
  2. Create a folder in wp-content/themes directory in your WordPress installation. If you have selected TwentySeventeen as the parent theme, name your new folder as TwentySeventeen-Child.
  3. Create a file named style.css in the newly created child theme folder. Edit the file and paste the following code into

/*

Theme Name:   Twenty Seventeen Child Theme

Template:     twentyseventeen

*/

You can add more details to this file, like author name and version etc. but as we are keeping things simple, we can get by with adding only essential information. Save the file with this information added.

  1. Create a file in the WordPress child theme named functions.php. We will use this file to copy, or inherit as it is usually said, parent theme styles. Copy the following code in the functions.php file and save it.

add_action( ‘wp_enqueue_scripts’, ‘enqueue_parent_styles’ );

 

function enqueue_parent_styles() {

wp_enqueue_style( ‘parent-style’, get_template_directory_uri().’/style.css’ );

}

Now, you are ready to activitate the child theme. Go to WordPress and activate the theme.