register_block_template( string $template_name, array|string $args = array() ): WP_Block_Template|WP_Error

In this article

Register a block template.

Parameters

$template_namestringrequired
Template name in the form of plugin_uri//template_name.
$argsarray|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

WP_Block_Template|WP_Error The registered template object on success, WP_Error object on failure.

Source

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

Changelog

VersionDescription
6.7.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.