pre_get_block_file_template filter-hookWP 5.9.0

Filters the block templates array before the query takes place.

Return a non-null value to bypass the WordPress queries.

Usage

add_filter( 'pre_get_block_file_template', 'wp_kama_pre_get_block_file_template_filter', 10, 3 );

/**
 * Function for `pre_get_block_file_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: `'wp_template'` or '`wp_template_part'`.
 *
 * @return WP_Block_Template|null
 */
function wp_kama_pre_get_block_file_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(string)
Template unique identifier (example: theme_slug//template_slug).
$template_type(string)
Template type: 'wp_template' or 'wp_template_part'.

Changelog

Since 5.9.0 Introduced.

Where the hook is called

get_block_file_template()
pre_get_block_file_template
wp-includes/block-template-utils.php 835
$block_template = apply_filters( 'pre_get_block_file_template', null, $id, $template_type );

Where the hook is used in WordPress

Usage not found.