get_template_directory_uri pointing to parent theme not child theme

get_template_directory_uri() will always return the URI of the current parent theme.

To get the child theme URI instead, you need to use get_stylesheet_directory_uri().

You can find these in the documentation, along with a list of other useful functions for getting various theme directory locations.


If you prefer to use a constant, then TEMPLATEPATH is akin to calling get_template_directory() (i.e. the parent theme), and STYLESHEETPATH is akin to calling get_stylesheet_directory() (i.e. the child theme).

These constants are set by WordPress core in wp-includes/default-constants.php and basically look like this:

define('TEMPLATEPATH', get_template_directory());
...
define('STYLESHEETPATH', get_stylesheet_directory());

If there is no child theme, then both the ‘template’ and ‘stylesheet’ functions will return the parent theme location.

Note the difference between these functions and the functions ending in _uri – these will return the absolute server path (eg. /home/example/public_html/wp-content/yourtheme), whereas the _uri functions will return the public address (aka URL) – eg. http://example.com/wp-content/themes/yourtheme.

Leave a Comment