HomeWORDPRESSWhat is a Child Theme?

What is a Child Theme?

A child theme in WordPress is a theme that inherits all the features, styles, and functionality of another theme (called the parent theme) but allows you to modify or add to it without changing the parent theme’s files.


Why Use a Child Theme?

  1. Safe Updates – You can update the parent theme without losing customizations.
  2. Customization – Modify styles, layouts, or functions without touching original code.
  3. Fallback Support – If a file isn’t in the child theme, WordPress loads it from the parent theme.
  4. Organized Development – Keeps your custom changes separate from core theme files.

How to Create a Child Theme

Create a new folder in /wp-content/themes/, e.g., mytheme-child/.

Inside it, create a style.css file with this header:

/*
Theme Name: MyTheme Child
Template: mytheme
*/

Theme Name = name of your child theme

Template = folder name of the parent theme

Import parent styles in functions.php:

<?php
add_action( 'wp_enqueue_scripts', 'my_child_theme_styles' );
function my_child_theme_styles() {
    wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
}

Activate your child theme in Appearance → Themes.


💡 Quick Analogy:
Think of the parent theme as a blueprint for a house, and the child theme as a renovation — you can repaint rooms, change layouts, or add new features without redrawing the original blueprint.

Share: 

No comments yet! You be the first to comment.

Leave a Reply

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