get_block_templates filter-hookWP 5.9.0

Filters the array of queried block templates array after they've been fetched.

Usage

add_filter( 'get_block_templates', 'wp_kama_get_block_templates_filter', 10, 3 );

/**
 * Function for `get_block_templates` filter-hook.
 * 
 * @param WP_Block_Template[] $query_result  Array of found block templates.
 * @param array               $query         Optional. Arguments to retrieve templates.
 * @param string              $template_type wp_template or wp_template_part.
 *
 * @return WP_Block_Template[]
 */
function wp_kama_get_block_templates_filter( $query_result, $query, $template_type ){

	// filter...
	return $query_result;
}
$query_result(WP_Block_Template[])
Array of found block templates.
$query(array)

Optional. Arguments to retrieve templates.

  • slug__in(array)
    List of slugs to include.

  • wp_id(int)
    Post ID of customized template.
$template_type(string)
wp_template or wp_template_part.

Changelog

Since 5.9.0 Introduced.

Where the hook is called

get_block_templates()
get_block_templates
wp-includes/block-template-utils.php 736
return apply_filters( 'get_block_templates', $query_result, $query, $template_type );

Where the hook is used in WordPress

Usage not found.