get_single_template()
get_single_template() 检索当前模板或父模板中单个模板的路径。适用于单个帖子、单个附件和单…
get_single_template()
检索当前模板或父模板中单个模板的路径。适用于单个帖子、单个附件和单个自定义帖子类型。
Retrieve path of single template in current or parent template. Applies to single Posts, single Attachments, and single custom post types.
目录锚点:#说明#返回#源码
说明(Description)
另见函数 get_query_template()
返回(Return)
(string)单个模板文件的完整路径。
源码(Source)
/**
* Retrieve path of single template in current or parent template.
*
* The template path is filterable via the dynamic {@see '$type_template'} hook,
* e.g. 'single_template'.
*
* @since 1.5.0
*
* @see get_query_template()
*
* @return string Full path to single template file.
*/
function get_single_template() {
$object = get_queried_object();
$templates = array();
if ( ! empty( $object->post_type ) )
$templates[] = "single-{$object->post_type}.php";
$templates[] = "single.php";
return get_query_template( 'single', $templates );
}| 更新版本 | 源码位置 | 使用 | 被使用 |
|---|---|---|---|
| 4.7.0 | wp-includes/template.php:505 | 0 | 4 |
类别:WordPress 函数手册、
本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。

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