To create a child theme for any theme, you will need to follow these steps:
- Create a new folder in your WordPress installation’s
wp-content/themesdirectory. This folder will contain your child theme files. - Create a
style.cssfile in the new folder. This file will contain the styles for your child theme. - In the
style.cssfile, add the following lines at the top:
/*
Theme Name: My Child Theme
Theme URI:
Description: My child theme
Author: Your Name
Author URI:
Template: parent-theme-folder-name
Version: 1.0.0
*/
- Replace
My Child Themewith the name of your child theme, andparent-theme-folder-namewith the folder name of the parent theme. - Add any custom styles for your child theme in the
style.cssfile below the comments. - Create a
functions.phpfile in the new folder. This file will contain the functions for your child theme. - In the
functions.phpfile, add the following lines:
<?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 through the WordPress admin dashboard by going to Appearance > Themes.
That’s it! Your child theme should now be active and you can start customizing the appearance of your site by modifying the styles in the style.css file and adding custom functions in the functions.php file.