Title: pre_get_block_template
Published: February 3, 2022
Last modified: May 20, 2026

---

# apply_filters( ‘pre_get_block_template’, WP_Block_Template|null $block_template, string $id, string $template_type )

## In this article

 * [Description](https://developer.wordpress.org/reference/hooks/pre_get_block_template/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/hooks/pre_get_block_template/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/hooks/pre_get_block_template/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/hooks/pre_get_block_template/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/hooks/pre_get_block_template/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/hooks/pre_get_block_template/?output_format=md#wp--skip-link--target)

Filters the block template object before the query takes place.

## 󠀁[Description](https://developer.wordpress.org/reference/hooks/pre_get_block_template/?output_format=md#description)󠁿

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

## 󠀁[Parameters](https://developer.wordpress.org/reference/hooks/pre_get_block_template/?output_format=md#parameters)󠁿

 `$block_template`[WP_Block_Template](https://developer.wordpress.org/reference/classes/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. Either `'wp_template'` or `'wp_template_part'`.

## 󠀁[Source](https://developer.wordpress.org/reference/hooks/pre_get_block_template/?output_format=md#source)󠁿

    ```php
    $block_template = apply_filters( 'pre_get_block_template', null, $id, $template_type );
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/block-template-utils.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/block-template-utils.php#L1301)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/block-template-utils.php#L1301-L1301)

## 󠀁[Related](https://developer.wordpress.org/reference/hooks/pre_get_block_template/?output_format=md#related)󠁿

| Used by | Description | 
| [get_block_template()](https://developer.wordpress.org/reference/functions/get_block_template/)`wp-includes/block-template-utils.php` |

Retrieves a single unified template object using its id.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/hooks/pre_get_block_template/?output_format=md#changelog)󠁿

| Version | Description | 
| [5.9.0](https://developer.wordpress.org/reference/since/5.9.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fpre_get_block_template%2F)
before being able to contribute a note or feedback.