get_block_template
Filters the queried block template object after it's been fetched.
Usage
add_filter( 'get_block_template', 'wp_kama_get_block_template_filter', 10, 3 );
/**
* Function for `get_block_template` filter-hook.
*
* @param WP_Block_Template|null $block_template The found block template, or null if there isn't one.
* @param string $id Template unique identifier (example: 'theme_slug//template_slug').
* @param string $template_type Template type. Either 'wp_template' or 'wp_template_part'.
*
* @return WP_Block_Template|null
*/
function wp_kama_get_block_template_filter( $block_template, $id, $template_type ){
// filter...
return $block_template;
}
- $block_template(WP_Block_Template|null)
- The found block template, or null if there isn't one.
- $id(string)
- Template unique identifier (example: 'theme_slug//template_slug').
- $template_type(string)
- Template type. Either 'wp_template' or 'wp_template_part'.
Changelog
| Since 5.9.0 | Introduced. |
Where the hook is called
get_block_template
wp-includes/block-template-utils.php 1347
return apply_filters( 'get_block_template', $block_template, $id, $template_type );