WPDev.one
Core Function
View Source on Trac ↗

register_block_type_from_metadata()

register_block_type_from_metadata( mixed $file_or_folder, mixed $args = array() )

Registers a block type from the metadata stored in the `block.json` file.

Parameters 2 required

Name / Type Description
string

$file_or_folder Path to the JSON file with metadata definition for the block or path to the folder where the `block.json` file is located. If providing the path to a JSON file, the filename must end with `block.json`.

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.5.0
Source File
wp-includes/blocks.php
Advertisement