WordPress: How to create a child theme?

Last Updated:
Contents
WordPress themes are “customizable” by default. Once you activate them, you can configure them in a standard way. However, you will quickly reach their limits if you want to push the customization of your site and make it more differentiated.
Therefore, it is recommended, if not imperative, to create a child theme if you want to make changes (even minor ones) to your theme. An update of the parent theme will overwrite all your modifications/customizations.
What is a WordPress child theme?
A child theme is based on your parent theme. By activating it, it will take all the features of the parent theme without ever modifying it. No more risk to lose your modifications during an update!
All the file copies you will place in your child theme (same name and same directory) will overwrite the original files without deleting them.
Copy only the files you want to modify, it is not necessary to copy the whole theme.
How to create a WordPress child theme?
To create a child theme, simply create a new folder in the FTP at the same level as your parent theme.
/wp-content/themes/child-theme/
For your theme to be recognized and activated, two files must be created:
functions.php style.css
Here is the code to integrate in functions.php which will be used to activate your child theme and associate a new style sheet:
<?php /** ** activation theme **/ add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' ); function theme_enqueue_styles() { wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' ); }
Here is the description of the style.css file to integrate so that the style sheet can be recognized.
/* Theme Name: Child Theme Description: Palms Web's Child Theme Author: Palms Web Author URI: https://palms-web.com Template: child-theme Version: 0.1.0 */
Description fields of the style.css file:
/* Theme Name: The name of the child theme Description: The description of the child theme Author: The author of the child theme Author URI: The url of the author's website Template: The folder name of the parent theme as written on the FTP Version: The version for information */
It is important to respect this case, otherwise your child theme will not work.
How to create a child theme with a WordPress plugin?
Child Theme Configurator by Lilaea Media is a free and very easy to use extension to create your child theme.