get_block_templates
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 Arguments to retrieve templates. All arguments are optional. * @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)
Arguments to retrieve templates. All arguments are optional.
-
slug__in(string[])
List of slugs to include. -
wp_id(int)
Post ID of customized template. -
area(string)
A 'wp_template_part_area' taxonomy value to filter by (for 'wp_template_part' template type only). - post_type(string)
Post type to get the templates for.
-
- $template_type(string)
- wp_template or wp_template_part.
Changelog
Since 5.9.0 | Introduced. |
Where the hook is called
get_block_templates
wp-includes/block-template-utils.php 1054
return apply_filters( 'get_block_templates', $query_result, $query, $template_type );