Child themes are considered the best way to personalize your WordPress themes. A child theme inherits all the characteristics and…


HOW TO CREATE A WORDPRESS CHILD THEME

Child themes are considered the best way to personalize your WordPress themes. A child theme inherits all the characteristics and appearance of its main theme. You can customize it without affecting the parent theme. This allows you to easily update the parent theme without worrying about losing your changes.

How To Set Up a WordPress Child Theme

This tutorial will show you how to set up child theme manually.

Requirements:
Make sure your parent theme is present in the Appearance -> Themes page, otherwise it will not work.

Here as example, we are using theme Twenty Sixteen the default WordPress theme.

Creating a Child Theme Manually

Step 1: Create a folder and name it on parent theme. Ex: twentysixteen-child
Step 2: Create a file titled style.css
Step 3: Open the style.css and write below information

/*
Theme Name: Twenty Sixteen Child
Template: twentysixteen
*/

Here one important thing to notice is the Template: twentysixteen.

This tells WordPress that our theme is a child theme and that our parent theme directory name is twentysixteen. The parent folder name is case-sensitive. If we provide WordPress with Template: Twentysixteen, then it will not work.

Step 4: Create a file titled functions.php and paste below code.


<?php
add_action( 'wp_enqueue_scripts', 'enqueue_child_theme_styles', PHP_INT_MAX);
function enqueue_child_theme_styles() {
wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );
}
?>

Step 5: Now Zip the folder and upload it via Appearance -> Themes -> Add New
Step 6: Activate the theme.

Leave a Reply

Your email address will not be published. Required fields are marked *