get_block_templates
Filter HookDescription
Filters the array of queried block templates array after they've been fetched. }Hook Information
File Location |
wp-includes/block-template-utils.php
View on GitHub
|
Hook Type | Filter |
Line Number | 1253 |
Hook Parameters
Type | Name | Description |
---|---|---|
WP_Block_Template[]
|
$query_result
|
Array of found block templates. |
array
|
$query
|
{ Arguments to retrieve templates. All arguments are optional. |
string
|
$template_type
|
wp_template or wp_template_part. |
Usage Examples
Basic Usage
<?php
// Hook into get_block_templates
add_filter('get_block_templates', 'my_custom_filter', 10, 3);
function my_custom_filter($query_result, $query, $template_type) {
// Your custom filtering logic here
return $query_result;
}
Source Code Context
wp-includes/block-template-utils.php:1253
- How this hook is used in WordPress core
<?php
1248 * @type string $area A 'wp_template_part_area' taxonomy value to filter by (for 'wp_template_part' template type only).
1249 * @type string $post_type Post type to get the templates for.
1250 * }
1251 * @param string $template_type wp_template or wp_template_part.
1252 */
1253 return apply_filters( 'get_block_templates', $query_result, $query, $template_type );
1254 }
1255
1256 /**
1257 * Retrieves a single unified template object using its id.
1258 *
PHP Documentation
<?php
/**
* Filters the array of queried block templates array after they've been fetched.
*
* @since 5.9.0
*
* @param WP_Block_Template[] $query_result Array of found block templates.
* @param array $query {
* 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.
* }
* @param string $template_type wp_template or wp_template_part.
*/
Quick Info
- Hook Type: Filter
- Parameters: 3
- File: wp-includes/block-template-utils.php
Related Hooks
Related hooks will be displayed here in future updates.