The Child Theme is used to ensure that your modifications are preserved and your changes made won’t overwritten by updates of the theme.
If you need more information please read here the official documentation here or follow these steps to create the child theme.
The first step in creating a child theme is to create the child theme directory folder in wp-content/themes.
It is recommended that the name of your child theme directory is appended with -child
and that there are no spaces in your child theme directory name. The child theme name will be for example:
hotelbooking-child
Now you have to create the child theme’s stylesheet (style.css). The stylesheet must begin with the following details about the Theme in the form of comments. (stylesheet header)
Here an example of the Hotel Booking Child theme style:
/* Theme Name: HotelBooking Child Theme URI: https://themeforest.net/collections/2503200-nicdark-wordpress-themes Description: Wonderful theme for your Business. Author: Nicdark Author URI: http://www.nicdarkthemes.com Template: hotelbooking Version: 1.0 License: http://www.nicdarkthemes.com License URI: http://www.nicdarkthemes.com Tags: one-column, two-columns, right-sidebar, custom-header, custom-menu, editor-style, featured-images, microformats, post-formats, rtl-language-support, sticky-post, translation-ready, accessibility-ready Text Domain: hotelbooking-child */
The only required child theme file is style.css, but functions.php is necessary to enqueue styles correctly, check the next step.
The first line of your child theme’s functions.php will be an opening PHP tag <?php
, after which you can enqueue your parent theme stylesheet.
In Hotel Booking Child theme for example you will have :
<?php add_action( 'wp_enqueue_scripts', 'enqueue_parent_theme_style' ); function enqueue_parent_theme_style() { wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' ); }
Your child theme is now ready for activation. Log in to your site’s administration panel, and go to Administration Panels > Appearance > Themes. You should see your child theme listed and ready for activation.