Child Themes and Theme Structure

How to create a child theme

  • Create a folder in your themes directory giving it the name of new theme.
  • Create style.css file and print this inside where template references the name of the parent theme that’s referenced in enqueue:
Theme Name:   Theme Name Here
Theme URI:    https://www.themeurl.com/
Description:  A Parent child theme 
Author:       Christine Wilson
Author URI:   https://www.christinewilson.ca
Template:     twentytwentyone
Version:      1.0.0
Text Domain:  themenamehere
  • Create a file called functions.php and add enqueue scripts info:
/* enqueue scripts and style from parent theme */
    
function main_scripts() {
    wp_enqueue_style( 'themenamehere', get_stylesheet_uri(),
    array( 'twenty-twenty-one-style' ), wp_get_theme()->get('Version') );
}
add_action( 'wp_enqueue_scripts', 'main_scripts');

Theme structure

Here’s all the possibilities inside your theme:

Possible folder structure (taken from WordPress)

assets (dir)
      - css (dir)
      - images (dir)
      - js (dir)
inc (dir)
template-parts (dir)
      - footer (dir)
      - header (dir)
      - navigation (dir)
      - page (dir)
      - post (dir)
404.php
archive.php
comments.php
footer.php
front-page.php
functions.php
header.php
index.php
page.php
README.txt
rtl.css
screenshot.png
search.php
searchform.php
sidebar.php
single.php
style.css

Leave a Reply

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