get_template_directory_uri() 将始终返回当前父主题的URI。
要获取子主题URI,需要使用get_stylesheet_directory_uri().
你可以找到这些in the documentation, 以及用于获取各种主题目录位置的其他有用函数的列表。
如果你喜欢使用常数,那么TEMPLATEPATH 类似于呼叫get_template_directory() (即父主题),以及STYLESHEETPATH 类似于呼叫get_stylesheet_directory() (即儿童主题)。
这些常量由WordPress core在中设置wp-includes/default-constants.php 基本上是这样的:
define(\'TEMPLATEPATH\', get_template_directory());
...
define(\'STYLESHEETPATH\', get_stylesheet_directory());
如果没有子主题,则“template”和“stylesheet”函数都将返回父主题位置。
请注意这些函数与以_uri - 这些将返回绝对服务器路径(例如。/home/example/public_html/wp-content/yourtheme), 鉴于_uri 函数将返回公共地址(又名URL)-例如。http://example.com/wp-content/themes/yourtheme.