register_block_template()WP 6.7.0

Register a block template.

No Hooks.

Return

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

Usage

register_block_template( $template_name, $args );
$template_name(string) (required)
Template name in the form of plugin_uri//template_name.
$args(array|string)

-

Default: array()

  • 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.

Changelog

Since 6.7.0 Introduced.

register_block_template() code WP 6.7.1

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