WPDev.one
Core Function
View Source on Trac ↗

register_block_type()

register_block_type( mixed $block_type, mixed $args = array() )

Registers a block type. The recommended way is to register a block type using

Parameters 2 required

Name / Type Description
mixed

(string | WP_Block_Type) $block_type Block type name including namespace, or alternatively a path to the JSON file with metadata definition for the block, or a path to the folder where the `block.json` file is located, or a complete WP_Block_Type instance. In case a WP_Block_Type is provided, the $args parameter will be ignored.

Required
array

$args Optional. Array of block type arguments. Accepts any public property of `WP_Block_Type`. See WP_Block_Type::__construct() for information on accepted arguments. Default empty array.

Required

Return Value

((WP_Block_Type)
| false) The registered block type on success, or false on failure.

Function Information

Since Version
5.0.0
Source File
wp-includes/blocks.php
Advertisement