Title: _add_block_template_info
Published: February 3, 2022
Last modified: February 24, 2026

---

# _add_block_template_info( array $template_item ): array

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/_add_block_template_info/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/_add_block_template_info/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/_add_block_template_info/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/_add_block_template_info/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/_add_block_template_info/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/_add_block_template_info/?output_format=md#wp--skip-link--target)

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

Attempts to add custom template information to the template item.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/_add_block_template_info/?output_format=md#parameters)󠁿

 `$template_item`arrayrequired

Template to add information to (requires `'slug'` field).

## 󠀁[Return](https://developer.wordpress.org/reference/functions/_add_block_template_info/?output_format=md#return)󠁿

 array Template item.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/_add_block_template_info/?output_format=md#source)󠁿

    ```php
    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;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/block-template-utils.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/block-template-utils.php#L476)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/block-template-utils.php#L476-L488)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/_add_block_template_info/?output_format=md#related)󠁿

| Uses | Description | 
| [wp_get_theme_data_custom_templates()](https://developer.wordpress.org/reference/functions/wp_get_theme_data_custom_templates/)`wp-includes/global-styles-and-settings.php` |

Returns the metadata for the custom templates defined by the theme via theme.json.

  | 
| [wp_theme_has_theme_json()](https://developer.wordpress.org/reference/functions/wp_theme_has_theme_json/)`wp-includes/global-styles-and-settings.php` |

Checks whether a theme or its parent has a theme.json file.

  |

| Used by | Description | 
| [_get_block_template_file()](https://developer.wordpress.org/reference/functions/_get_block_template_file/)`wp-includes/block-template-utils.php` |

Retrieves the template file from the theme for a given slug.

  | 
| [_get_block_templates_files()](https://developer.wordpress.org/reference/functions/_get_block_templates_files/)`wp-includes/block-template-utils.php` |

Retrieves the template files from the theme.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/_add_block_template_info/?output_format=md#changelog)󠁿

| Version | Description | 
| [5.9.0](https://developer.wordpress.org/reference/since/5.9.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2F_add_block_template_info%2F)
before being able to contribute a note or feedback.