Posted April 4, 2016
Why do I need a child theme?
If you’ve modified any of your theme’s files directly, you’ll lose any changes you’ve made when your theme is updated. By using a child theme, you can override your theme’s settings without running the risk of losing your work.
How to create a child theme:
In this example, we’ll create a child theme for the Twentysixteen theme that comes pre-installed with WordPress.
1. Create a new folder for your child theme in “/wp-content/themes” of your WordPress installation. To keep it simple, we’ll call our folder “twentysixteen-child”:
1 2 3 |
mkdir twentysixteen-child |
2. Go into your new folder
1 2 3 |
cd twentysixteen-child |
3. Create a file named “style.css” containing the following:
1 2 3 4 5 6 7 8 |
/* Theme Name: Twenty Sixteen Child Description: Twenty Sixteen Child Theme Author: John Doe Template: twentysixteen */ |
4. Create a file named functions.php containing the following:
1 2 3 4 5 6 7 8 9 |
<?php add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' ); function theme_enqueue_styles() { wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' ); } ?> |
Speak Your Mind