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