register_block_template()WP 6.7.0

Register a block template.

Хуков нет.

Возвращает

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

Использование

register_block_template( $template_name, $args );
$template_name(строка) (обязательный)
Template name in the form of plugin_uri//template_name.
$args(массив|строка)

-

По умолчанию: array()

  • title(строка)
    Optional. Title of the template as it will be shown in the Site Editor and other UI elements.

  • description(строка)
    Optional. Description of the template as it will be shown in the Site Editor.

  • content(строка)
    Optional.
    По умолчанию: 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(строка)
    Optional. Slug of the plugin that registers the template.

Список изменений

С версии 6.7.0 Введена.

Код register_block_template() WP 6.7.1

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