_add_block_template_info()WP 5.9.0

Attempts to add custom template information to the template item.

Internal function — this function is designed to be used by the kernel itself. It is not recommended to use this function in your code.

No Hooks.

Return

Array. Template item.

Usage

_add_block_template_info( $template_item );
$template_item(array) (required)
Template to add information to (requires 'slug' field).

Changelog

Since 5.9.0 Introduced.

_add_block_template_info() code WP 6.5.2

function _add_block_template_info( $template_item ) {
	if ( ! wp_theme_has_theme_json() ) {
		return $template_item;
	}

	$theme_data = wp_get_theme_data_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;
}