0
0
WordpressHow-ToBeginner · 4 min read

How to Create a Child Theme in WordPress Quickly

To create a WordPress child theme, make a new folder in wp-content/themes with a style.css file that includes a Template header pointing to the parent theme. Then enqueue the parent theme styles in a functions.php file to inherit styles and functionality.
📐

Syntax

Creating a child theme requires two main files inside a new folder: style.css and functions.php.

  • style.css: Contains theme info and imports parent styles.
  • functions.php: Loads the parent theme stylesheet properly.
  • Template header: In style.css, the Template line specifies the parent theme folder name.
css
/*
Theme Name: My Child Theme
Template: twentytwentyone
*/

/* Add your custom styles below */
💻

Example

This example creates a child theme for the parent theme named twentytwentyone. It shows the minimal style.css and functions.php needed.

php
/* style.css */
/*
Theme Name: My Child Theme
Template: twentytwentyone
*/

/* Custom styles go here */


<?php
// functions.php
function my_child_theme_enqueue_styles() {
    wp_enqueue_style('parent-style', get_template_directory_uri() . '/style.css');
}
add_action('wp_enqueue_scripts', 'my_child_theme_enqueue_styles');
?>
Output
Child theme loads and inherits styles from twentytwentyone parent theme.
⚠️

Common Pitfalls

  • Forgetting to set the correct Template name in style.css causes the child theme not to link to the parent.
  • Not enqueueing the parent styles in functions.php can break styling.
  • Copying parent files directly instead of overriding only needed files leads to maintenance issues.
css
/* Wrong style.css header example */
/*
Theme Name: My Child Theme
Template: wrongparentname
*/

/* Correct style.css header example */
/*
Theme Name: My Child Theme
Template: twentytwentyone
*/
📊

Quick Reference

FilePurposeKey Content
style.cssDefines child theme and links to parentTheme Name, Template header, custom CSS
functions.phpLoads parent theme styleswp_enqueue_style() for parent stylesheet
Folder nameChild theme folderAny unique name, placed in wp-content/themes

Key Takeaways

Always set the correct Template name in style.css to link to the parent theme.
Use functions.php to enqueue the parent theme stylesheet properly.
Create a new folder for your child theme inside wp-content/themes.
Avoid copying entire parent theme files; override only what you need.
Activate the child theme in WordPress admin to apply your customizations.