register_block_type – no block available in block editor
-
Fresh/clean install of WordPress 6.1.1 (no 3rd party plugins/themes)- PHP 8.0.x
Using the following code in functions.php of twentytwentytwo theme.
function wrm_testblock() { register_block_type('wrm/testblock', array( 'attributes' => array( 'title' => array( 'type' => 'string', 'default' => 'TEST', ), 'imageUrl' => array( 'type' => 'string', 'default' => '', ), 'linkUrl' => array( 'type' => 'string', 'default' => '', ), ), )); } add_action('init', 'wrm_testblock');
According to any documentation and other examples I have read, I would expect to see the new block available in the blocks panel in the editor.
But that’s not the case. The new block is nowhere.
If I do intentionally a mistake -e.g. type the block name with capitals, WP will let me know about my mistake, which means that the function gets called.I might be missing something obvious that I am not able to see.
Does the block need to have any other attributes in order to become available in the blocks panel? Or do I need anything else to make this work?
All the docs I read and many examples show that I can register a block only by its name and that it should appear as block option in the panel.
Any idea?
- The topic ‘register_block_type – no block available in block editor’ is closed to new replies.