pre_get_block_file_template WordPress Filter Hook

The pre_get_block_file_template hook is used to filter the path of the template file that is used to render a block. The hook is called before the template is retrieved, and can be used to override the default template file that would be used. This can be useful if you want to use a different template for a specific block, or if you want to use a different template for all blocks.

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

Filters the block templates array before the query takes place.


Description

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


Top ↑

Parameters

$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'.


Top ↑

Source

File: wp-includes/block-template-utils.php

View on Trac



Top ↑

Changelog

Changelog
VersionDescription
5.9.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.