It’s been a while since I’ve done anything in WordPress, and I wanted to customise the 2020 theme. Which seems nice
To make a child theme, you need to start with 3 things:
- A new directory
- functions.php
- style.css
Directory
Add a new directory – named your theme name, in the path:
wp-content/themes/
functions.php
Create a new file in this directory called functions.php and add the following code to inherit all the styles from the parent theme
<?php
//* Code goes here
add_action( 'wp_enqueue_scripts', 'enqueue_parent_styles' );
function enqueue_parent_styles() {
wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );
}
style.css
Create a new file in this directory called style.css and paste the following code – I don’t know the bare minimum that’s needed to mark it as a theme – but change the information from Your Name to … well
/*
Theme Name: Your Name
Theme URI: https://terryprobert.co.uk/theme
description: Your Description
Author: You
Author URI: https://terryprobert.co.uk/
Template: twentytwenty
Version: 1.0.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Tags: light, dark, two-columns, right-sidebar, responsive-layout, accessibility-ready
Text Domain: twenty-twenty-child
*/
Rock and Roll
Choose your theme from the Appearance ›› Themes in WordPress, you’ve now made your own child theme!
Overriding templates, customising CSS comes next.
Bare in mind – the theme that’s been created requires the parent theme to be installed. WordPress’s 2020 theme is pretty solid.
WordPress version: 5.3.2