theme_{$post_type}_templates

過濾鉤子
apply_filters( "theme_{$post_type}_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:
定義位置
相關勾子
theme_templatestheme_auto_update_setting_templateregister_post_type_argstype_templaterest_route_for_post_type_items
相關方法
get_post_type_archive_templateget_post_type_labelsget_page_templatesget_page_templateget_date_templateget_paged_template
引入
4.7.0
棄用
-

theme_{$post_type}_templates是一個WordPress過濾鉤子,允許開發者為特定的文章型別新增自定義模板。

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

鉤子名稱的動態部分,$post_type,指的是文章型別。

可能的鉤子名稱包括:

  • theme_post_templates
  • theme_page_templates
  • theme_attachment_templates
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
$post_templates = (array) apply_filters( "theme_{$post_type}_templates", $post_templates, $this, $post, $post_type );
$post_templates = (array) apply_filters( "theme_{$post_type}_templates", $post_templates, $this, $post, $post_type );
$post_templates = (array) apply_filters( "theme_{$post_type}_templates", $post_templates, $this, $post, $post_type );

常見問題

FAQs
檢視更多 >