{$type}_template

過濾鉤子
apply_filters( "{$type}_template", $template, $type, $templates )
引數
  • (string) $template Path to the template. See locate_template().
    Required:
  • (string) $type Sanitized filename without extension.
    Required:
  • (string[]) $templates A list of template candidates, in descending order of priority.
    Required:
定義位置
相關勾子
theme_templatesget_template_partcomments_templatetype_template_hierarchyprint_media_templates
相關方法
get_page_templateget_templatelocate_templateget_page_templatesis_page_templateget_date_template
引入
4.8.0
棄用
-

{$type}_template 是 WordPress 中的過濾器鉤子,它修改由”$type” 定義的特定媒體型別的模板檔案的路徑。 這可用於更改媒體在網站前端的顯示方式。

按型別過濾被查詢模板的路徑。

鉤子名稱的動態部分,$type,指的是要載入的檔案的檔名–減去副檔名和任何非字母數字的字元分隔詞–。這個鉤子也適用於作為模板層次結構的一部分載入的各種型別的檔案。

可能的鉤子名稱包括:

  • 404_template
  • archive_template
  • attachment_template
  • author_template
  • category_template
  • date_template
  • embed_template
  • frontpage_template
  • home_template
  • index_template
  • page_template
  • paged_template
  • privacypolicy_template
  • search_template
  • single_template
  • singular_template
  • tag_template
  • taxonomy_template
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
return apply_filters( "{$type}_template", $template, $type, $templates );
return apply_filters( "{$type}_template", $template, $type, $templates );
return apply_filters( "{$type}_template", $template, $type, $templates );

常見問題

FAQs
檢視更多 >