Filter hook 'get_block_template'

in WP Core File wp-includes/block-template-utils.php at line 1325

View Source

get_block_template

Filter Hook
Description
Filters the queried block template object after it's been fetched.

Hook Information

File Location wp-includes/block-template-utils.php View on GitHub
Hook Type Filter
Line Number 1325

Hook Parameters

Type Name Description
WP_Block_Template|null $block_template The found block template, or null if there isn't one.
string $id Template unique identifier (example: 'theme_slug//template_slug').
string $template_type Template type. Either 'wp_template' or 'wp_template_part'.

Usage Examples

Basic Usage
<?php
// Hook into get_block_template
add_filter('get_block_template', 'my_custom_filter', 10, 3);

function my_custom_filter($block_template, $id, $template_type) {
    // Your custom filtering logic here
    return $block_template;
}

Source Code Context

wp-includes/block-template-utils.php:1325 - How this hook is used in WordPress core
<?php
1320  	 *
1321  	 * @param WP_Block_Template|null $block_template The found block template, or null if there isn't one.
1322  	 * @param string                 $id             Template unique identifier (example: 'theme_slug//template_slug').
1323  	 * @param string                 $template_type  Template type. Either 'wp_template' or 'wp_template_part'.
1324  	 */
1325  	return apply_filters( 'get_block_template', $block_template, $id, $template_type );
1326  }
1327  
1328  /**
1329   * Retrieves a unified template object based on a theme file.
1330   *

PHP Documentation

<?php
/**
	 * Filters the queried block template object after it's been fetched.
	 *
	 * @since 5.9.0
	 *
	 * @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'.
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 3
  • File: wp-includes/block-template-utils.php
Related Hooks

Related hooks will be displayed here in future updates.