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.

$template_type

(string)wp_template or wp_template_part.


Top ↑

Source

File: wp-includes/block-template-utils.php

View on Trac



Top ↑

Changelog

Changelog
VersionDescription
5.9.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.