pre_get_block_template WordPress Filter Hook
The pre_get_block_template hook is a great way to modify the way that WordPress generates block templates. This hook allows you to change the template path, as well as other template properties, before the template is rendered. This is a great way to customize the way your blocks are displayed on your website.
apply_filters( 'pre_get_block_template', WP_Block_Template|null $block_template , string $id , string $template_type ) #
Filters the block template object before the query takes place.
Description
Return a non-null value to bypass the WordPress queries.
Parameters
- $block_template
(WP_Block_Template|null)Return block template object to short-circuit the default query, or null to allow WP to run its normal queries.
- $id
(string)Template unique identifier (example: theme_slug//template_slug).
- $template_type
(string)Template type:
'wp_template'
or 'wp_template_part'
.
Source
Changelog
Version | Description |
---|---|
5.9.0 | Introduced. |