Using WordPress child theme to customize your WordPress theme is the safest route possible. Because your customization will be saved in a different folder and it won’t get lost when you update the parent theme.

What is Child Theme?

Child theme is the mirror reflection of a theme. Whatever changes you make to the reflection will not affect the original or parent theme. But if the parent theme makes any changes it will be visible in your child theme.

Why You Should Be Using Child Themes

Using WordPress child themes to modify the theme is one of the safest and recommended way. Your changes will not be deleted if your parent theme gets updated. Another benefit of using child theme is if your child theme modification creates issue you can always deactivate the child and revert back to parent theme.

How To set Up a WordPress Child Theme

  1. Creating a Child Theme Manually
  2. Creating a Child Theme Using Plugin

Requirements:

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

wordpress child theme

Creating a Child Theme Manually

Step 1: Create a folder and name it anything you like. Ex: optimizer-child
Step 2: Create a file titled style.css
Step 3: Open the style.css and write below information

/*
 Theme Name: My Theme Child
 Template: My theme
 */

Step 4: Create a file titled functions.php and paste below code to import the parent themes style.

<?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 );
}
?>

wordpress child theme

Create a Child Theme Using Plugin

If you don’t want to jump through these hoops you can use free wordpress plugins to do that for you. There are lot of free plugins that lets you create a child theme easily. Eg: One-Click Child Theme, Child Theme Configurator, Child Theme Creator by Orbisius etc.
In this article we will see how to create a child theme using One-Click Child Theme plugin. Follow these step by step instructions to get it configured.

wordpress child theme

Step 1: Download One-Click Child Theme plugin
Step 2: log into the admin area of your site (http://yoursite.com/wp-login.php)
Step 3: Go to Plugins -> Add New
Step 4: Click on Upload plugin to upload the plugin, then click on Activate plugin
Step 5: Now go to Appearance -> Themes, make sure the theme you wish to create child theme for is activated. (For example: if you wish to create a child theme of twenty sixteen make sure twenty sixteen is activated.)
Step 6: Click on the theme thumbnail, then click on Child Theme
Step 7: After click that, you will be taken to child theme configuration page. Write Theme name, Description and author field.
Step 8: Click on Create Child
Step 9: Now your child theme is ready and activated.

wordpress child theme

Editing Other Template Files

If you want to add any custom functions to your WordPress child theme, you have to write them in your child themes functions.php. You can even make any structural or layout changes of your parent theme using child theme.
Lets go through this step by step

For instance, you have created a child theme of Twenty Sixteen Theme. Now you want to change how single page are display in twenty Sixteen. The single page is located at twentysixteen/template-parts/content-single.php
Step 1 : Create a content-single.php in your child theme folder. But ensure it will overwrite the parent theme we have to follow the exact file name & structure.

Step 2: Create a folder and place the file inside that folder. Make sure the path looks exactly like the parent theme.
Parent Theme : twentysixteen/template-parts/content-single.php
Child Theme : twentysixteen-child/template-parts/content-single.php

Step 3: Now you can write your own code in the content-single.php and it will overwrite parent file

Using this method you can edit and overwrite any template of parent theme. You just have to make sure file name and folder path are identical.

LEAVE A REPLY

Please enter your comment!
Please enter your name here