Title: register_block_template
Published: November 13, 2024
Last modified: August 20, 2026

---

# register_block_template( string $template_name, array|string $args = array() ): 󠀁[WP_Block_Template](https://developer.wordpress.org/reference/classes/wp_block_template/)󠁿|󠀁[WP_Error](https://developer.wordpress.org/reference/classes/wp_error/)󠁿

## In this article

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

Register a block template.

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

 `$template_name`stringrequired

Template name in the form of `plugin_uri//template_name`.

`$args`array|stringoptional

 * `title` string
 * Optional. Title of the template as it will be shown in the Site Editor and other
   UI elements.
 * `description` string
 * Optional. Description of the template as it will be shown in the Site Editor.
 * `content` string
 * Optional. Default content of the template that will be used when the template
   is rendered or edited in the editor.
 * `post_types` string[]
 * Optional. Array of post types to which the template should be available.
 * `plugin` string
 * Optional. Slug of the plugin that registers the template.

Default:`array()`

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

 [WP_Block_Template](https://developer.wordpress.org/reference/classes/wp_block_template/)
|[WP_Error](https://developer.wordpress.org/reference/classes/wp_error/) The registered
template object on success, [WP_Error](https://developer.wordpress.org/reference/classes/wp_error/)
object on failure.

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

    ```php
    function register_block_template( $template_name, $args = array() ) {
    	return WP_Block_Templates_Registry::get_instance()->register( $template_name, $args );
    }
    ```

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

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

| Uses | Description | 
| [WP_Block_Templates_Registry::get_instance()](https://developer.wordpress.org/reference/classes/wp_block_templates_registry/get_instance/)`wp-includes/class-wp-block-templates-registry.php` |

Utility method to retrieve the main instance of the class.

  |

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

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

## User Contributed Notes

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