wppaste
WordPress

apply_filters( 'pre_get_block_templates', \WP_Block_Template[]|null $block_templates, array $query, string $template_type )

Since
5.9.0
Filters the block templates array 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_templates\WP_Block_Template[]|null
Return an array of block templates to short-circuit the default query, or null to allow WP to run its normal queries.
$queryarray
{ Arguments to retrieve templates. All arguments are optional.
@type string[] $slug__in List of slugs to include.
@type int $wp_id Post ID of customized template.
@type string $area A 'wp_template_part_area' taxonomy value to filter by (for 'wp_template_part' template type only).
@type string $post_type Post type to get the templates for.
}
  • $slug__instring[]

    List of slugs to include.
  • $wp_idint

    Post ID of customized template.
  • $areastring

    A 'wp_template_part_area' taxonomy value to filter by (for 'wp_template_part' template type only).
  • $post_typestring

    Post type to get the templates for.
$template_typestring
Template type. Either 'wp_template' or 'wp_template_part'.

Where this hook fires · 1

  • wp-includes/block-template-utils.php:1128get_block_templates()

Source code

	 *     @type int      $wp_id     Post ID of customized template.	 *     @type string   $area      A 'wp_template_part_area' taxonomy value to filter by (for 'wp_template_part' template type only).	 *     @type string   $post_type Post type to get the templates for.	 * }	 * @param string $template_type Template type. Either 'wp_template' or 'wp_template_part'.	 */	$templates = apply_filters( 'pre_get_block_templates', null, $query, $template_type );	if ( ! is_null( $templates ) ) {		return $templates;	} 	$post_type     = $query['post_type'] ?? '';	$wp_query_args = array(

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 7.1.0 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.