get_template_directory_uri pointing to parent theme not child theme

The problem I am having is that the get_template_directory_uri is pointing to the parent theme like site/wp-content/themes/twentythirteen/myGallery/gallery_functions_include.php

but I want it to point to my child theme which should be site/wp-content/themes/child-twentythirteen/myGallery/gallery_functions_include.php

what I am using is include (TEMPLATEPATH . '/myGallery/gallery_functions_include.php');


You should move your custom templates, those that are not controlled by the active theme, to a child folder.

Keep the theme separate from all customized files this way the theme can be updated without losing your custom work.

Your out-of-the-box theme lives here
Your child theme lives here

Your custom styles and templates and all your includes (things like custom javascript, images that are not saved to WP, custom fonts, json data files, and any plugins that you might enqueue) should be moved to child folder OUTSIDE of theme.

\themes\some_theme-child\ (all your custom php template files here)

For your custom style pages (not the theme's overridden style.css) enqueue with wp_enqueue_style( 'some-css', get_stylesheet_directory() . '/style/some.css' , false, '0.0.1', 'all');

Use get_stylesheet_directory_uri() with your xhr calls, etc.

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.


include (TEMPLATEPATH . '/path-to/my-file.php');


include dirname( __FILE__ ) . '/path-to/my-file.php';

this should work for most common issues

Similar questions

My style in my child theme loads after the parent theme, but it breaks stuff: How do I load it before the parent theme?
I'm building my child theme, but including materialize css that I want to use, breaks the entire site when enqueued in functions.php. How do I change that?
Child theme and its parent theme both identify as parent theme wordpress
I am trying to install a child theme on wordpress. for whatever reason I cannot install it because it says both themes identify as the child theme. I was having an issue when I created my child theme header so I went into the wordpress codex and just copied their style and replaced the relevant info. here is the style.css for the regular theme: and...
get_template_directory_uri() and other URL tags not working in theme
So, I'm trying to add get_template_directory_uri or bloginfo() to my header.php file to create relative paths for the CSS and JS files in the theme. E.g., In theory this should show Problem is, when I view the <head> tag in source all I see is: All the other template tags work in my files (get_permalink(), the_title(), etc.), but this one isn...
i want to get the parent id, only on parent -> child -> child page
here is Hierarchy Parent (id=34) Child Child of child-1 Child of child-2 Child of child-3 Child of child-4 I am at child of child, i Just want to show sibblings of child of child if parent is '34', like this I used the below function in function.php, but its not working properly Thanks Furqan Khyraj
Listing all child-pages of a parent-page on the parent-page and each child-page?
I have a parent page called "About". This page has three child pages "Members", "Information", "Contact". I want to list all the child-pages on all four pages, also the parent-page. So right now I have this which lists all the child-pages only on the parent-page. But I want all the pages also listed on each individual child page. How do I do that?
WordPress list categories dropdown with parent-child relation and child under it's parent
I am attempting to display a category dropdown (select) with parent categories and child categories tagged under the child category. Example: Instead what I am getting is the following: Here is my shortcode: My question here is, which of the arguments are responsible for the correct ordering of the children under the parent taxonomy category? Is th...

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy.