What is a WordPress Child Theme
A WordPress child theme is a WordPress theme that inherits its functionality from another WordPress theme, the parent theme. Child themes are often used when you want to customize or tweak an existing WordPress theme without losing the ability to upgrade that theme. In the past, there was no easy way of updating WordPress themes without losing all the custom styling and changes that you had made.
Why use a Child Theme?
- If you modify a theme directly and it is updated, then your modifications may be lost. By using a child theme you will ensure that your modifications are preserved.
- Using a child theme can speed up development time.
- Using a child theme is a great way to learn about WordPress theme development.
- Portability, you can transfer your child theme to any site you work on
Files You Need to Create
- Create a folder with the name of your theme with -child added to the end – ex: if you’re using twentyseventeen name the folder twentyseventeen-child
- create 2 text files
- style.css
- functions.php
/* * Theme Name: TwentySeventeen Child * Theme URI: https://stopha.com * Description: TwentySevenenteen Child Theme * Author: Maryann Reissig * Author URI: http://stopha.com * Template: TwentySeventeen * Version: 1.0.0 * License: GNU General Public License v2 or later * License URI: http://www.gnu.org/licenses/gpl-2.0.html * */
functions.php:
<?php function my_theme_enqueue_styles() { wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' ); } add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
Changing Template Files
Another powerful thing you can control with a child theme are the template files for a theme. If you want to build your own custom post type templates, archives, or any other template, you can override the parent theme with one of your own.
Copy the template file you want to use from your parent theme (or create your own!) and store them in the child theme directory, they will override any file in the parent directory to your liking.
Resources
https://www.hostinger.com/tutorials/how-to-create-wordpress-child-theme
https://codex.wordpress.org/Child_Themes
https://www.wpbeginner.com/beginners-guide/what-is-a-theme-framework/
Child Theme Configurator Plugin – Plugin to create a child theme from an already-edited parent theme. Great resource to convert work you’ve already done to a child them!
Free Custom Post Type UI creator plugin – Create CPTs (like Pods or CustomPress) – works great with Advanced Custom Fields
Ultimate CSV Importer – Shout out to this plugin – it’s worth the cost for the pro version IMO!
Contact me with any questions!