Template Path in WordPress Child Themes

WordPress Child themes are a great Idea to extend the theme a bit without getting your hands dirty with the big deal, but I encountered a problem with my child theme when I wanted to load some of my Javascript files which I kept with in the child theme so that the parent theme remains unchanged and all the development is also done in one directory.

When I tried loading the Javascript using the Template path obtained by

$template_path = get_bloginfo('template_url');

I got the path to the parent theme which of course is wrong in my case as my JS file was in child theme’s folder.

I had to make a custom function to get my child theme’s path. I am copying this function below for people who are facing the same issue. Feel free to copy this function into your functions.php file of your child theme. If you don’t have a functions.php in your child theme then create one

function get_childTheme_url() {
    return dirname( get_bloginfo('stylesheet_url') );

After copying this function in functions.php, call this function anywhere to get the path to your child theme; as shown below

$template_path = get_childTheme_url();

Share this article if it was of any help, that might help others as well.

  • Wouter

    Thanks for this function! I used this initially but I then I came across get_stylesheet_directory_uri(). This also works :)

  • Franklyoliver

    works like a charm. any reason the people at wordpress did not include this.

  • Selectiveform

    It’s not working for me.

    • which version of wordpress are you using ? whats the issue ?

  • Blitz

    Hi Umair,
    You missed your own trick with this. There is no need to make a function.php call at all, and WP hasn’t left this feature out.To call a file from the child theme folder you just use You use stylesheet_url (which is in the the child folder), not template_url (which is the parent theme).Much more elegant! ;-)

  • Blitz

    Hi Umair,

    Sorry late night and I missed something! It is this, not the above stylesheet_url:

  • Fabian

    get_stylesheet_directory_uri() returns an absolute server path (eg: /home/user/public_html/wp-content/themes/my_theme), not a URI.

    So the code of Umair is very nice if you are requesting any file from your Childtheme.

    Great work Umair

    • Thanks @05db1d262ff3c3efd89b279be43489bb:disqus , I am glad it helped

  • get_stylesheet_directory_uri(); for child theme directory

    and get_stylesheet_uri(); for the stylesheet within the child theme directory.

    So you don’t need to use this function anymore.

  • Absolute path for child theme can be:


  • Esteban Utz

    Thanks for the post, it worked for me!