How to create a Child Theme in WordPress

How To Create and Customise a Child Theme In WordPress

WordPress is suitable for anyone who is interested in gaining full control over their sites. With WordPress, you can run a website independently and easily customise it as well. One of the great features of WordPress is the ability to create a child theme – this is when you are able to load only the things you need from a parent WordPress theme. Child themes are perfect for when you find a theme you want to use, but find it is rather bloated and is loading scripts and styles that you are not using etc.

In this blog, our own Liverpool web design experts will be addressing the steps for creating and customising a Child Theme in WordPress. But first, you have to know that the child theme is fully dependent on the parent theme to work. It won’t be able to do anything or even get activated in the absence of its parent.

Folder Creation

You have to start navigating to the “wp-content/themes” present in the installation of your WordPress. Once you get there, you will have to make a new folder regarding your child theme. You can use the exact name for your theme’s folder as the parent one, but you have to append it using “-child.” Let’s use a random name and call the folder as “twentyseventeen-child.” You can use any name of your choice as long as you don’t insert spaces.

Style Sheet Creation

A style sheet possesses the code that is responsible for determining the website’s design. Here, you need to make a brand-new text file and name it as “style.css” You need to insert the following coding to make it work:


/*
Theme Name: Twenty Seventeen Child
Theme URI: https://example.com/twenty-seventeen-child/
description: >-
Twenty Seventeen Child Theme
Author: John Doe
Author URI: https://example.com
Template: twentyseventeen
Version: 1.0.0
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Tags: light, dark, two-columns, right-sidebar, responsive-layout, accessibility-ready
Text Domain: twenty-seventeen-child
*/

Activating Child Theme

Now, you need to go to the ‘Appearance’ tab and click on the “Themes” section present in the backend of WordPress. Here, you will be able to locate your child theme. Once you press on the ‘Theme Details’ option, you will be able to view the content of your style sheet header. Proceed in clicking on the “Activate” button.

Creating Functions.php

This file enables changing and addition of both features and functionality to a WordPress site. Here, it might possess both native and PHP WordPress functions. You can even create your very own functions. It basically contains a code, which changes how a site appears and behaves. To create the file, you just need a text file called “functions.php” From there; you need to paste this code:


<?php
//* Code goes here

You just need to insert the opening tag of “php”, and you are all set. But you need to realise that you won’t be requiring “functions.php” in case you aren’t planning to utilise PHP for modifying your theme.

WordPress Child Theme Customisation

An easy way to customise your theme would be through CSS. It enables you to customise dimensions, colours, fonts, and more design elements. If you are skilled in CSS, then you can successfully change your site’s whole layout. It will be possible for you to override just about any styles within the parent’s theme by having “style.css” in place. You can do so by inserting codes in the style sheet of the child’s theme.

But if you have called the styles of the parent’s theme inside the “style.css” file, then you need to insert any type of custom styles underneath the statement that says “@import” You will be able to see from the given snippet:


/*
Theme Name: Twenty Seventeen Child Theme
description: >-
A child theme of the Twenty Seventeen default WordPress theme
Author: Nick Schäferhoff
Template: twentyseventeen
Version: 1.0.0
*/
// Custom styles go here

Summary

Creating a child theme with WordPress isn’t as complicated as one would think. You just need a folder and two files. Even if a child theme is quite simple, it is very powerful. The child theme enables you to safely and fully customise a site without having to edit any of the core files.