What is a child theme and how to create one?

Child Theme Tutorial: What is a Child Theme and how to setup one?

Spread the love

You can use any theme you want in WordPress to suit your needs. However, while customizing the theme and using plugins it is easy for beginners to break the theme, miss out the simple syntax, etc. A child theme in WordPress allows you to make changes to your website without worrying about breaking the code or causing errors. You can always go back to the parent theme. Also, if you are using a lot of plugins it becomes indispensable to use a child theme because you never know if the plugin is well-written and updated regularly.

How to create a child theme?

Step 1.

Download Filezilla. Log in and open your wp-content folder and find the themes folder. Create a new folder and name it: ‘MyThemeName-child’.  [Here, MyThemeName is the name of the theme you are using.]

Step 2.

In this new child theme folder, create a file called style.css and copy paste the code below. You may use Notepad or any other text editor. Change the Theme Name, URI, Description and Author attribute as per your discretion. The below example of creating a child theme is for Twenty Sixteen which is a free to use theme on WordPress.

/*
Theme Name: mythemename-child
Theme URI: https://growthjack.com/
Description: mythemename child theme
Author: yourname
Author URI: http://deepakjha.com
Template: mythemename
Version: 1.0.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Tags: light, dark, two-columns, right-sidebar, responsive-layout, accessibility-ready
Text Domain: mythemename-child
*/
@import url("../mythemename/style.css");
/* Use custom CSS from here on. */

Note: The code is case-sensitive, so if you are not sure it is better to use lower case all over.

Step 3.

Create another file in the folder, name it functions.php and paste the code below into the file and save it. A lot of times you’d need to make certain modifications in this child theme file.

 <!--?php function my_theme_enqueue_styles() { $parent_style = 'parent-style'; // This is 'twentyfifteen-style' for the Twenty Fifteen theme. wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' ); wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() . '/style.css', array( $parent_style ), wp_get_theme()-&gt;get('Version')&lt;br ?--> );
}
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
?>;

Step 3.
Activate the child theme: Go to the Appearance section of your WordPress admin panel and click on themes. Among the installed themes you’d notice your child theme (mythemename-child). Activate it and enjoy.

Posted in Blogging, Social Media, Tools And Resources, WordPress Hacks and tagged , , , .

Leave a Reply