theme_templates
云策文档标注
概述
theme_templates 过滤器用于修改主题的页面模板列表。它允许开发者在获取模板时动态调整或添加模板选项。
关键要点
- 过滤器名称:theme_templates
- 参数:$post_templates(模板文件名键控的模板头名数组)、$theme(主题对象)、$post(当前编辑的文章对象或 null)、$post_type(文章类型)
- 用途:在 WP_Theme::get_page_templates() 中调用,用于返回指定文章类型的主题文章模板
- 引入版本:WordPress 4.9.6
代码示例
$post_templates = (array) apply_filters( 'theme_templates', $post_templates, $this, $post, $post_type );
原文内容
Filters list of page templates for a theme.
Parameters
Source
$post_templates = (array) apply_filters( 'theme_templates', $post_templates, $this, $post, $post_type );
Changelog
| Version | Description |
|---|---|
| 4.9.6 | Introduced. |