Using Child Themes

Oftentimes with our WordPress sites we want to amend the default styling or layouts that are used within the particular theme we have assigned

WordPress makes this very easy to do, and customization can really help improve the look and feel of our site

The main file that would be amended should we decide to do this is style.css within the theme’s root folder, but any file that is part of that theme can be tailored to meet our needs

A problem with doing this is that when the theme we are using gets updated by its creator or vendor – all of our customization will be lost, and this is where Child Themes come into play

The child theme effectively ‘inherits’ all of the attributes of its parent, whilst allowing individual tailoring of any of its components

If your site is hosted under a variant of Linux – here is what you need to do:

Navigate to your site’s themes folder – eg

/home/my-sites/cbot01/wp-content/themes

Create a new folder with the name you want to assign the child theme (I generally use part of the site’s name) and change to that folder

mkdir cbot01
cd cbot01

Use your regular editor to create a file called style.css and populate it with entries that look like this:

/*
Theme Name: CBOT01
Theme URI: http://quadshot.com
Description: CBOT01
Author: Chris Bell
Author URI: http://quadshot.com
Template: twentyfifteen
Version: 1.0.0
Tags: light, dark, two-columns, right-sidebar, responsive-layout, accessibility-ready
Text Domain: cbot01
*/

@import url(“../twentyfifteen/style.css”);

/* =Theme customization starts here
————————————————————– */

The most important line here is the one that begins @import which needs to refer to the theme you are going to assign as the parent – in this case the WordPress Twenty Fifteen theme

Once this has been done, and the correct ownership’s and permissions have been assigned, in the site’s WP Dashboard go to Appearance / Themes – and you should see your newly created child theme listed

BlogImage047

If you click on the button for the theme marked Theme Details – you will see that it is indeed a child of the parent you had selected

BlogImage048

Once activated – it is then ready to be used, and any updates to its parent theme will leave any modifications you had made to the child in place

There is an excellent article in the WordPress Codex that describes this in detail:

https://codex.wordpress.org/Child_Themes