get_template_directory_uri()
get_template_directory_uri() 检索主题目录URI。Retrieve theme d…
get_template_directory_uri()
检索主题目录URI。
Retrieve theme directory URI.
目录锚点:#返回#源码#笔记
返回(Return)
(string)模板目录URI。
源码(Source)
/**
* Retrieve theme directory URI.
*
* @since 1.5.0
*
* @return string Template directory URI.
*/
function get_template_directory_uri() {
$template = str_replace( '%2F', '/', rawurlencode( get_template() ) );
$theme_root_uri = get_theme_root_uri( $template );
$template_dir_uri = "$theme_root_uri/$template";
/**
* Filter the current theme directory URI.
*
* @since 1.5.0
*
* @param string $template_dir_uri The URI of the current theme directory.
* @param string $template Directory name of the current theme.
* @param string $theme_root_uri The themes root URI.
*/
return apply_filters( 'template_directory_uri', $template_dir_uri, $template, $theme_root_uri );
}| 更新版本 | 源码位置 | 使用 | 被使用 |
|---|---|---|---|
| 1.5.0 | wp-includes/theme.php:346 | 12 | 4 |
笔记(Notes)
此函数返回根主题的URL。如果使用子主题,并且要将URL返回到当前子主题,请改用get_stylesheet_directory_uri()。
使用get_template_directory_uri()将静态图像与其html中的正确路径链接:
使用get_template_directory_uri()将具有正确路径的脚本排队。
类别:WordPress 函数手册、
本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。

还没有任何评论,赶紧来占个楼吧!