get_block_templates WordPress Filter Hook
The get_block_templates hook allows you to programmatically add new templates to the WordPress Block Editor. This hook is useful if you want to add custom templates to your theme, or if you want to create a library of templates that can be used by other themes or plugins.
apply_filters( 'get_block_templates', WP_Block_Template[] $query_result , array $query , string $template_type ) #
Filters the array of queried block templates array after they’ve been fetched.
Parameters
- $query_result
(WP_Block_Template[])Array of found block templates.
- $query
(array)Arguments to retrieve templates.
- 'slug__in'
(array) List of slugs to include. - 'wp_id'
(int) Post ID of customized template.
- 'slug__in'
- $template_type
(string)wp_template or wp_template_part.
Source
Changelog
Version | Description |
---|---|
5.9.0 | Introduced. |