WordPress is_child_theme() Function

Beginner
4 min read
Updated: Nov 2026
3 examples
Conditional tag

Definition

In WordPress, is_child_theme() returns true when the active theme is a child theme. It returns false when a normal (parent) theme is active.

Theme and plugin developers use it to load extra files or settings only when a child theme is in use. It does not need the main query.

Syntax

Use it as the test of an if statement.

WordPress
if ( is_child_theme() ) {
  // code for the true path
} else {
  // code for the false path
}
CallWhat it does
is_child_theme()True if a child theme is active.
! is_child_theme()True if a parent theme is active.
get_stylesheet_directory()The folder of the active theme, which is the child folder when a child theme is active.

Use get_template_directory() for the parent folder and get_stylesheet_directory() for the active theme folder.

Full declaration
WordPress
is_child_theme(): bool

Parameters

ParameterDescription
NoneThis function takes no parameters.

Return Value

Return ValueDescription
booltrue if a child theme is active, otherwise false.

WordPress Examples

Three short theme examples. Each one shows what prints on the true path and the false path.

Example 1 — Print a note about the theme

Tell the developer which type of theme is active.

WordPress
<?php
if ( is_child_theme() ) {
  echo 'Child theme: ' . wp_get_theme()->get( 'Name' );
} else {
  echo 'Parent theme: ' . wp_get_theme()->get( 'Name' );
}

How It Works

  1. is_child_theme() compares the theme and the parent theme.
  2. wp_get_theme() gives details of the active theme.
  3. The else branch covers the normal theme.

Example 2 — Load a file from the right folder

Pick the child folder when it exists.

WordPress
<?php
$dir = is_child_theme() ? get_stylesheet_directory() : get_template_directory();
echo $dir;

How It Works

  1. The short ? : form picks one of two folders.
  2. get_stylesheet_directory() is the active theme folder.
  3. get_template_directory() is always the parent folder.

Example 3 — Load the parent style first

A child theme usually needs the parent stylesheet too.

WordPress
function mytheme_styles() {
  if ( is_child_theme() ) {
    wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
  }
  wp_enqueue_style( 'theme-style', get_stylesheet_uri() );
}
add_action( 'wp_enqueue_scripts', 'mytheme_styles' );

How It Works

  1. The check runs when WordPress loads styles.
  2. A child theme loads the parent stylesheet first.
  3. get_stylesheet_uri() is the active theme style.css.

Frequently Asked Questions

It returns true or false (a bool). Use it inside an if statement.
The child style.css has a Template line that names the parent theme folder.
No. It is the same on every page because it only looks at the active theme.
get_template_directory() is the parent theme folder. get_stylesheet_directory() is the active theme folder, so it is the child folder when a child theme is active.

Next: is_date()

Check if the current page is any date-based archive.

is_date() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

13 people found this page helpful