Skip to content

Register Block Type #63695

Answered by t-hamano
carmopereira asked this question in Q&A
Jul 18, 2024 · 1 comments · 1 reply
Discussion options

You must be logged in to vote
register_block_type(__DIR__ . '/build/block2.json');

My guess is that this file doesn't exist. Generally, when building multiple blocks, the structure will look something like this:

build/
 ├ Main/
 │ ├ block.json
 │ ├ index.asset.php
 │ └ index.js
 └ GlobalUpdateCart/
   ├ block.json
   ├ index.asset.php
   └ index.js
src/
 ├ Main/
 │ ├ block.json
 │ ├ index.js
 │ ├ edit.js
 │ └ save.js
 └ GlobalUpdateCart/
 │ ├ block.json
 │ ├ index.js
 │ ├ edit.js
 │ └ save.js

Then you should be able to register the block like this:

function create_block_carmo_order_form_to_cart_block_init() {
	register_block_type(__DIR__ . '/build/Main');
	register_block_type(__DIR__ . '/build/GlobalUpdateCart');
}
a…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@carmopereira
Comment options

Answer selected by carmopereira
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants