The main reason to create a child theme is so that your edits do not get overwritten when doing any sort of updates to your main (parent) theme. The steps are fairly simple.
This example is for the Twenty Sixteen theme.
Navigate into your themes folder.
cd /<your_website_root_folder>/wp-content/themes/
Create a child directory within your themes folder and cd into it.
mkdir twentysixteen-child; cd twentysixteen-child
Create two files, style.css and functions.php.
Create style.css
Note: Update the appropriate fields.
/*
Theme Name: Twenty Sixteen Child
Theme URI: http://itsmetommy.com/twentysixteen-child
Description: Twenty Sixteen Child Theme
Author: Tommy Elmesewdy
Author URI: http://itsmetommy.com
Template: twentysixteen
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: twentysixteen-child
*/
/* Your code goes below this line */
Create functions.php
<?php
add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
function theme_enqueue_styles() {
wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
}
?>
Now go to your WordPress Dashboard > Appearance > Themes. You will notice that you now have a new theme called Twenty Sixteen Child.
WARNING: I ended up having to redo my Colors and Widgets once I activated the new child theme
Click Activate.
2 responses to “WordPress Child Themes”
[…] choose Open Sans as my font for my site (as of writing this post). Now that I’ve created a child theme, I want to change the font. To do this, we will be working with our style.css and functions.php […]
[…] you’ve read my previous blogs, you’d know I am using a child theme. I noticed that the theme didn’t come with a full width page template, so here are the […]