According to the documentation (https://codex.wordpress.org/Child_Themes and https://developer.wordpress.org/reference/functions/get_template_directory_uri/), it’s my understanding that

get_template_directory_uri() 

will return the URL of the parent theme’s directory if used within a child theme. But that is not happening for me.

In a child theme I’m trying to develop, when I use

get_template_directory_uri() 

it returns the URL for the child theme’s directory, not it’s parent theme directory. If I click on Theme Details for the child theme on the manage themes page, WordPress states that the theme is a child of another theme, exactly as I would expect. I have a

Template: parent

line in the child theme’s style.css.

Other relevant facts:

  • I’m using WordPress Multi-Site
  • I developed the parent theme and I’m using it for one of the other sites within my Multi-Site and it works just fine
  • Both themes (parent and child) are Network activated and accessible in the site I’m working in
  • I tried pointing the child theme at the twentyfourteen theme and I’m seeing the same behavior, so I don’t think it’s an issue with the parent theme.
  • I disabled all of my plugins to see if one of them was the issue with no success – none of the plugins appear to be the cause of this
  • I created a copy of twentyfourteen and made it a child theme of my parent theme and same problem happens
  • In my copy of twentyfourteen, I then also added a Template: line in style.css to make it a child them of twentyfourteen and I’m seeing the same behavior as well (i.e., the manage themes page states that the copied theme is a child of twentyfourteen but the get_template_directory_uri function isn’t giving me the parent theme’s directory)

Does anyone have any suggestions on what could be the issue here? Or am I misinterpreting how

get_template_directory_uri() 

is supposed to work?

Read more here: get_template_directory_uri() in child theme pointing at child theme


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: