{$type}_template_hierarchy

過濾鉤子
apply_filters( "{$type}_template_hierarchy", $templates )
引數
  • (string[]) $templates A list of template candidates, in descending order of priority.
    Required:
定義位置
相關勾子
type_templateget_template_parttemplate_redirectdefault_page_template_titlecomments_template_query_args
相關方法
get_template_hierarchyget_page_hierarchy_get_term_hierarchyget_template_directoryget_template_partget_template_directory_uri
引入
4.7.0
棄用
-

“{$type}_template_hierarchy”是 WordPress 中的一個動作鉤子,它在為特定媒體型別載入模板的過程中執行,如“$type”所定義。 它允許開發人員將自定義邏輯新增到模板層次結構中,並根據特定條件選擇合適的模板檔案。

過濾在檢索使用的模板時搜尋到的模板檔名的列表。

鉤子名稱的動態部分,$type,指的是要載入的檔案的檔名–減去副檔名和任何非字母數字的字元分隔詞–。陣列中的最後一個元素應該始終是該查詢型別的後備模板。

可能的鉤子名稱包括:

  • 404_template_hierarchy
  • archive_template_hierarchy
  • attachment_template_hierarchy
  • author_template_hierarchy
  • category_template_hierarchy
  • date_template_hierarchy
  • embed_template_hierarchy
  • frontpage_template_hierarchy
  • home_template_hierarchy
  • index_template_hierarchy
  • page_template_hierarchy
  • paged_template_hierarchy
  • privacypolicy_template_hierarchy
  • search_template_hierarchy
  • single_template_hierarchy
  • singular_template_hierarchy
  • tag_template_hierarchy
  • taxonomy_template_hierarchy
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
$templates = apply_filters( "{$type}_template_hierarchy", $templates );
$templates = apply_filters( "{$type}_template_hierarchy", $templates );
$templates = apply_filters( "{$type}_template_hierarchy", $templates );

常見問題

FAQs
檢視更多 >