Skip to content

Latest commit

 

History

History
37 lines (22 loc) · 1.56 KB

File metadata and controls

37 lines (22 loc) · 1.56 KB

Block Registration

All content in the WordPress block editor is a block.

This is similar to other editors like Medium, Notion, and MailChimp.

Blocks are usually interactive, so they have a React component to edit them.

In this exercise, we're going to register a block so the editor is aware of it.

The modern way to register a WordPress block is with a block.json file.

A block.json file must be present to be eligible for the Block Directory.

Also, WordPress recommends registering a block with PHP and JS.

Both registrations will be simple because of block.json.

Exercise

You're going to register the block in JS and PHP.

Look for 🚧 in the exercise files for where to edit.

In js/src/index.exercise.js, registerBlockType() will look like:

registerBlockType( block.name, {
	// edit component here.

Files

Solution

solution.mp4