template_directory
云策文档标注
概述
template_directory 是一个 WordPress 过滤器,用于修改活动主题目录的路径。它允许开发者自定义主题目录的路径,常用于主题开发或插件中。
关键要点
- template_directory 是一个过滤器 Hook,用于过滤活动主题目录的路径。
- 参数包括 $template_dir(活动主题目录路径)、$template(活动主题目录名)和 $theme_root(主题目录的绝对路径)。
- 源代码中通过 apply_filters 调用,返回过滤后的路径。
- 相关函数 get_template_directory() 用于检索活动主题的模板目录路径。
- 自 WordPress 1.5.0 版本引入。
原文内容
Filters the active theme directory path.
Parameters
$template_dirstring-
The path of the active theme directory.
$templatestring-
Directory name of the active theme.
$theme_rootstring-
Absolute path to the themes directory.
Source
return apply_filters( 'template_directory', $template_dir, $template, $theme_root );
Changelog
| Version | Description |
|---|---|
| 1.5.0 | Introduced. |