how to make a child theme in wordpress
First, create a new folder in the "/wp-content/themes/" directory for your child theme.
In the new folder, create a new file named "style.css". Add the following code at the beginning of the file:
/*
Theme Name: Twenty Seventeen Child
Theme URI: http://example.com/twenty-seventeen-child/
Description: Twenty Seventeen Child Theme
Author: John Doe
Author URI: http://example.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
Tags: light, dark, two-columns, right-sidebar, responsive-layout, accessibility-ready
Text Domain: twenty-seventeen-child
*/
- Create a new file named "functions.php" in the child theme directory. Add the following code to enqueue the parent theme's styles and scripts:
<?php
add_action( 'wp_enqueue_scripts', 'enqueue_parent_styles' );
function enqueue_parent_styles() {
wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );
}
Activate the child theme in the WordPress admin dashboard under "Appearance > Themes".
You can now modify the child theme's files to customize the appearance and functionality without altering the parent theme.