Child and Parent Theme Paths in WordPress

Quick Summary

  • get_stylesheet_directory() points to the active theme, including a child theme, while get_template_directory() always points to the parent theme.
  • Functions ending in uri return URLs for linking CSS, JavaScript and images, while the others return server paths for loading PHP files.
  • Parent themes should use the template functions, and since none of them add a trailing slash, start appended file names with a slash.

WordPress has two pairs of functions for child and parent theme paths, and the one you need depends on whether you’re working with a child theme. Each pair has a path version, for loading PHP files on the server, and a URI version, for linking CSS, JavaScript and images in the browser.

Current theme (child theme if one is active)

The stylesheet functions point to the active theme. With a child theme active, that’s the child theme’s folder; without one, it’s the theme itself.

PHP
get_stylesheet_directory()     // PATH (parent or child)
get_stylesheet_directory_uri() // URI (parent or child, checks for SSL)

Parent theme only

The template functions always point to the parent theme, even when a child theme is active. Without a child theme, they return the same folder as the stylesheet functions.

PHP
get_template_directory()     // PATH (parent only)
get_template_directory_uri() // URI (parent only, checks for SSL)

Which one to use

  • get_stylesheet_directory(): file path to the current theme directory.
  • get_stylesheet_directory_uri(): URL to the current theme directory.
  • get_template_directory(): file path to the parent theme directory.
  • get_template_directory_uri(): URL to the parent theme directory.

In a parent theme, use the template functions, so its files still load when someone adds a child theme. In a child theme, use the stylesheet functions for files in the child theme and the template functions for files in the parent, for example to enqueue the parent’s style.css. None of them add a trailing slash, so start the file name you append with /.

Share on X (opens in a new tab) Share on LinkedIn (opens in a new tab) Share on Facebook (opens in a new tab)

ChatGPT (opens in a new tab) Claude (opens in a new tab) Gemini (opens in a new tab) Perplexity (opens in a new tab) Grok (opens in a new tab)

More Insights

See More