How to Create and Customize Child Themes in WordPress - KrishaWeb

Dealing with Child Themes

What is the Parent Theme?

Parent theme is a theme that is further divided into many sub-themes. It contains all the files required for themes. The parent theme includes WordPress Template files and assets for the theme to work.

What is a Child Theme?

Child theme inherits its functionality from the parent theme. Child theme allows you to make changes within the parent theme and you can enhance the functionality or the look of the parent theme in such a way that if the parent theme is updated, the changes will not lost.

Elements of Child Theme

This includes, a style sheet, a template file, and a functions.php.

When to Use Child Theme?

It is the best way to customize WordPress themes. By creating a child theme, you can customize the theme without affecting the parent theme.

When Not to Use Child Theme?

The child theme is preferred for heavy customization. If you are not ready to put into an excessive change in the theme, then it is advised not to use it.

How to Create a Child Theme?

Child themes are easily customized and do not affect the parent theme in any way. It also allows the parent theme to update without tampering the changes in the child theme.

Below are the steps to create a child theme-

Create a Child Theme Folder

  • Create a new folder in wp-content/themes.
  • To avoid confusion, name the folder as the parent theme and suffix it with child.

Create a Style Sheet

It contains programming code for the theme. To create a style sheet first, we have to create a file and name it style.css. Then a code is written to make it functional. It contains the theme name, theme URI, description, template, author name and author URI etc.

Activate Child Theme

  • Appearances
  • Themes
  • Click on activate

Create Functions.php

These files allow changing, adding functionality, and features to the WordPress website.

Create a functions.php file and paste –

<?php

//* Code goes here

Inherit Parent Styles

It is to get the parent theme style into the child theme. There are two ways to do so.

  • Via CSS and the @import rule
  • Load the parent’s style sheet

Customizing Child Theme

  • Implementing custom styles
  • Overriding parent theme files
  • Working with template files
  • Using functions.php

Advantages of Child Theme

  • Modifications are easy
  • Separate from the parent theme
  • Parent themes can be updated without tampering the changes made
  • Saves the development time