Back to all posts

Create Multiple Custom Blocks in One Plugin


Once you’re comfortable creating a single block, you may want to package several custom blocks within a single plugin. This is ideal for building a block suite or a set of related blocks.

Step 1: Organize Your Plugin Structure

Inside your plugin’s src or main directory, create a subfolder for each block (e.g., first-blocksecond-block). Each folder should contain its own block.json, JavaScript, and optional PHP files for dynamic rendering.

Step 2: Register Each Block

In your main plugin PHP file, register each block by pointing to its build directory:

register_block_type(__DIR__ . '/build/first-block');
register_block_type(__DIR__ . '/build/second-block');
// Add more as needed

This ensures all your blocks are available in the editor

Step 3: Build and Test

  • Run npm start in your plugin directory to build all blocks.
  • Activate your plugin and confirm each block appears in the Block Editor.

Checkout this video for more detailed explaintion