How to Create a WordPress Child Theme

Are you looking to create a child theme in WordPress? WordPress child theme allows you change the functionality of the theme without having to edit the original/parent theme template files.

Firsty, create a new folder in your themes directory. You can do so using the cPanel or via FTP. The themes directory is the wp-content/themes. So let’s go through the above steps in detail. For this example, I will be creating a child theme for the Twenty Fifteen default theme.

To create a child theme, We create a style.css file in our child theme folder as shown below:

/*
 Theme Name:   Twenty Fifteen Child
 Theme URI:    http://yourwebsite.com/twentyfourteen-child/
 Description:  My first child theme, based on Twenty Fourteen
 Author:       Daniel Pataki
 Author URI:   http://danielpataki.com
 Template:     twentyfourteen
 Version:      1.0.0
 Tags:         black, green, white, light, dark, two-columns, three-columns, left-sidebar, right-sidebar, fixed-layout, responsive-layout, custom-background, custom-header, custom-menu, editor-style, featured-images, flexible-header, full-width-template, microformats, post-formats, rtl-language-support, sticky-post, theme-options, translation-ready, accessibility-ready, responsive-layout
 Text Domain:  twenty-fifteen -child
*/

/* write custom css */

Create a file named functions.php in the child theme folder, edit it, and paste the following:

<?php
/**
 * Enqueues child theme stylesheet, loading first the parent theme stylesheet.
 */
function esoft_custom_enqueue_child_theme_styles() {
  wp_enqueue_style( 'parent-theme-css', get_template_directory_uri() . '/style.css' );
}
add_action( 'wp_enqueue_scripts', 'esoft_custom_enqueue_child_theme_styles', 11 );
?>

Uploading and activating a child theme is no different than a normal theme, simply upload it via the Appearances > Themes page in your WordPress Dashboard and activate it. Before you upload it, you must first ZIP it.

Hopefully now you are able to create a child theme and make the customization that you like. Want to say something? Add it in the comments and I will get back to you.

Enjoy!

Leave a Comment

Your email address will not be published.