Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

_add_block_template_info() WordPress Function

The _add_block_template_info() function is used to add template information to a block when it is registered. This function is typically used to add template paths or callback functions for rendering a block.

_add_block_template_info( array $template_item ) #

Attempts to add custom template information to the template item.


Parameters

$template_item

(array)(Required)Template to add information to (requires 'slug' field).


Top ↑

Return

(array) Template item.


Top ↑

Source

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

function _add_block_template_info( $template_item ) {
	if ( ! WP_Theme_JSON_Resolver::theme_has_support() ) {
		return $template_item;
	}

	$theme_data = WP_Theme_JSON_Resolver::get_theme_data()->get_custom_templates();
	if ( isset( $theme_data[ $template_item['slug'] ] ) ) {
		$template_item['title']     = $theme_data[ $template_item['slug'] ]['title'];
		$template_item['postTypes'] = $theme_data[ $template_item['slug'] ]['postTypes'];
	}

	return $template_item;
}


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.