Create A Child Theme

Create a Theme folder –> create a file called style.css –> fill in the information as outlined below

/*
 Theme Name:     Helocon Child Theme
 Theme URI:      https://helocon.com
 Description:    Helocon Child Theme
 Author:         Helocon Team
 Author URI:     https://helocon.com
 Template:       Helocon
 Version:        1.0.0
*/
 
/* =Theme customization starts here
------------------------------------------------------- */

Enqueue the Parent and Child Theme Stylesheets

Create a file named functions.php and add this code

<?php
function my_theme_enqueue_styles() {
 
    $parent_style = 'parent-style';
 
    wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
    wp_enqueue_style( 'child-style',
        get_stylesheet_directory_uri() . '/style.css',
        array( $parent_style ),
        wp_get_theme()->get('Version')
    );
}
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
?>

For another example, if you are creating a child theme for the Twentyseventeen theme, you would replace the tag ‘parent-style’ with ‘twentyseventeen-style’ because when you search for the tag being used by the parent theme, you see this:

Each theme will be different so make sure and get this tag name correct.

Leave a Reply

Your email address will not be published. Required fields are marked *