Notice: Function wp_enqueue_script was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or login_enqueue_scripts hooks. This notice was triggered by the codepen-embed-script handle. Please see Debugging in WordPress for more information. (This message was added in version 3.3.0.) in /home/u577718808/domains/kwwd.co.uk/public_html/blog/wp-includes/functions.php on line 6114
Create A WordPress Child Theme – Katy's Code Bank

Create A WordPress Child Theme

In order to create a Child theme we need to add a minimum of two files

Create a new folder which will hold your child theme files and create a file called style.css which contains the following code:

/*
Theme Name: Your Child Theme Name
Theme URI: https://yourwebsite.com/
Author: Your Name
Author URI: https://yourwebsite.com/
Description: A child theme of [Parent Theme Name]
Template: [Parent Theme Name] // Replace with the actual parent theme name
Version: 1.0.0
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: [Your Child Theme Text Domain] // Optional, for translations Use the same in your functions
*/

Note: Remove the the sections that include “//” and following text.

You will then need to create a file named “functions.php” and include the following code:

<?php

// Load Parent Styles from the main theme into the child theme
function my_theme_enqueue_styles() {
    wp_enqueue_style( 'parent_theme_style', get_template_directory_uri() . '/style.css' );
    wp_enqueue_style( 'child_theme_style', get_stylesheet_uri() );
}
add_action("wp_enqueue_scripts", "my_theme_enqueue_styles");


?>

After that your Child Theme will be accessible in the Appearance > Themes Page

Disclaimer: The code on this website is provided "as is" and comes with no warranty. The author of this website does not accept any responsibility for issues arising from the use of code on this website. Before making any significant changes, ensure you take a backup of all files and do not work directly on a live/production website without thoughly testing your changes first.

Leave a Reply

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