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查询。

$block_template = apply_filters( 'pre_get_block_template', null, $id, $template_type );

常见问题

FAQs
查看更多 >