theme_templates

過濾鉤子
apply_filters( 'theme_templates', $post_templates, $this, $post, $post_type )
引數
  • (string[]) $post_templates Array of template header names keyed by the template file name.
    Required:
  • (WP_Theme) $theme The theme object.
    Required:
  • (WP_Post|null) $post The post being edited, provided for context, or null.
    Required:
  • (string) $post_type Post type to get the templates for.
    Required:
定義位置
相關勾子
print_media_templatestype_templatetheme_post_type_templatescomments_templatetheme_locale
相關方法
get_embed_templateget_home_templateget_templateget_page_templateslocate_templateget_page_template
引入
4.9.6
棄用
-

theme_templates是一個陣列,用來儲存你的主題中所有可用的模板。你可以使用這個陣列來為特定的頁面或文章以程式設計方式設定模板。theme_templates陣列是一個關聯陣列,其中鍵是模板名稱,值是模板檔案的完整路徑。

過濾主題的頁面模板的列表。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
$post_templates = (array) apply_filters( 'theme_templates', $post_templates, $this, $post, $post_type );
$post_templates = (array) apply_filters( 'theme_templates', $post_templates, $this, $post, $post_type );
$post_templates = (array) apply_filters( 'theme_templates', $post_templates, $this, $post, $post_type );

常見問題

FAQs
檢視更多 >