wppaste
WordPress

apply_filters( 'pre_get_block_template', WP_Block_Template|null $block_template, string $id, string $template_type )

Since
5.9.0
Filters the block template object before the query takes place.

Description

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

Compatibility

WordPress
since 5.9.0
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0).

Parameters

$block_templateWP_Block_Template|null
Return block template object to short-circuit the default query, or null to allow WP to run its normal queries.
$idstring
Template unique identifier (example: 'theme_slug//template_slug').
$template_typestring
Template type. Either 'wp_template' or 'wp_template_part'.

Where this hook fires · 1

  • wp-includes/block-template-utils.php:1289get_block_template()

Source code

	 *	 * @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'.	 */	$block_template = apply_filters( 'pre_get_block_template', null, $id, $template_type );	if ( ! is_null( $block_template ) ) {		return $block_template;	} 	$parts = explode( '//', $id, 2 );	if ( count( $parts ) < 2 ) {

Changelog

Introduced in 5.9.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 6.9.7 tag, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.