Other Tools By Katy: Code Snippets | Writing Progress Tracker | Threader: Easy Threads Maker | Word Cloud Maker

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 *