pre_get_block_template

過濾鉤子
apply_filters( 'pre_get_block_template', null, $id, $template_type )
引數
  • (WP_Block_Template|null) $block_template Return block template object to short-circuit the default query, or null to allow WP to run its normal queries.
    Required:
  • (string) $id Template unique identifier (example: theme_slug//template_slug).
    Required:
  • (string) $template_type Template type: `'wp_template'` or '`wp_template_part'`.
    Required:
定義位置
相關勾子
pre_get_block_templatespre_get_block_file_templateget_block_templateget_block_templatesget_block_file_template
相關方法
get_block_templateget_block_templates_get_block_template_fileresolve_block_templateget_block_file_template_get_block_templates_files
引入
5.9.0
棄用
-

pre_get_block_template是一個過濾鉤子,它允許你在一個區塊的模板被WordPress檢索和使用之前修改它的內容。

在進行查詢之前過濾塊樣板物件。

返回非空值以繞過WordPress查詢。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
$block_template = apply_filters( 'pre_get_block_template', null, $id, $template_type );
$block_template = apply_filters( 'pre_get_block_template', null, $id, $template_type );
$block_template = apply_filters( 'pre_get_block_template', null, $id, $template_type );

常見問題

FAQs
檢視更多 >