pre_get_block_templates

過濾鉤子
apply_filters( 'pre_get_block_templates', null, $query, $template_type )
引數
  • (WP_Block_Template[]|null) $block_templates Return an array of block templates to short-circuit the default query, or null to allow WP to run it's normal queries.
    Required:
  • (array) $query { Optional. Arguments to retrieve templates. @type array $slug__in List of slugs to include. @type int $wp_id Post ID of customized template. @type string $post_type Post type to get the templates for. }
    Required:
  • (string) $template_type wp_template or wp_template_part.
    Required:
定義位置
相關勾子
pre_get_block_templateget_block_templatespre_get_block_file_templateget_block_templateget_block_file_template
相關方法
get_block_templatesget_block_template_get_block_templates_files_get_block_templates_paths_get_block_template_fileresolve_block_template
引入
5.9.0
棄用
-

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

在進行查詢之前過濾塊模板陣列。

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

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

常見問題

FAQs
檢視更多 >