pre_get_block_template
Filters the block template object before the query takes place.
Return a non-null value to bypass the WordPress queries.
@since 5.9.0
@param 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. @param string $id Template unique identifier (example: theme_slug//template_slug). @param string $template_type Template type: 'wp_template' or 'wp_template_part'.
Использование
add_filter( 'pre_get_block_template', 'wp_kama_pre_get_block_template_filter', 10, 3 ); /** * Function for `pre_get_block_template` filter-hook. * * @param $null * @param $id * @param $template_type * * @return */ function wp_kama_pre_get_block_template_filter( $null, $id, $template_type ){ // filter... return $null; }
- $null
- -
- $id
- -
- $template_type
- -
Где вызывается хук
pre_get_block_template
wp-includes/block-template-utils.php 763
$block_template = apply_filters( 'pre_get_block_template', null, $id, $template_type );