There are three ways to build a custom WordPress block in 2026. They suit different blocks, and you can mix all three on one site, because the result of each is a standard WordPress block.
- React, with
@wordpress/create-block. WordPress's original way. You write the editor side in JavaScript and run a build. Best for a block that is really an app. - PHP only, built into WordPress 7.0. One PHP function, no JavaScript. Best for a block with a few plain settings.
- Fields and a template, with Gutenberg Control Blocks (GCB). Three plain files and no build step, with text, images and lists your client edits on the page. Best for the blocks a client changes every week: heroes, cards, team grids, galleries.
This guide shows the same small block built each way, what your client sees in the editor, and how to choose.
The details about WordPress core were checked against make.wordpress.org, developer.wordpress.org and the Gutenberg repository on 27 November 2026. The sources are listed in PHP-only blocks in WordPress 7.0. We make GCB, so read the third way knowing that.
What every WordPress block has
Whichever way you choose, a block is three things: a name and some metadata (block.json), a set of attributes that hold what the editor saves, and something that turns those attributes into HTML. The three ways differ in who writes the editor's side of it.
Way one: React and a build step
Scaffold a block with WordPress's own tool:
npx @wordpress/create-block@latest noticecd noticenpm startYou get a block.json, an edit.js for the editor, and either a save.js or a PHP render for the page. The editor side is a React component:
import { useBlockProps, RichText } from '@wordpress/block-editor'; export default function Edit( { attributes, setAttributes } ) { return ( <div { ...useBlockProps() }> <RichText tagName="p" value={ attributes.title } onChange={ ( title ) => setAttributes( { title } ) } placeholder="Write a notice" /> </div> );}What you get: complete control. Anything the block editor can do, your block can do, including editing on the canvas and any interface you care to build.
What it costs: a JavaScript build for every block, and two copies of the markup to keep in step, one in React for the editor and one for the page. Required fields, list limits and more than one InnerBlocks area are yours to write. For an app-like block, such as a calculator or a booking form, that cost is worth paying.
Way two: PHP only, in WordPress 7.0
WordPress 7.0 can register a block from PHP alone. You call register_block_type() with the autoRegister support and a render_callback:
add_action( 'init', function () { register_block_type( 'my-theme/notice', array( 'attributes' => array( 'title' => array( 'type' => 'string', 'default' => '', 'label' => __( 'Title', 'my-theme' ) ), 'size' => array( 'type' => 'string', 'enum' => array( 'small', 'medium', 'large' ), 'default' => 'medium' ), ), 'render_callback' => function ( $attributes ) { return sprintf( '<div %s>%s</div>', get_block_wrapper_attributes(), esc_html( $attributes['title'] ) ); }, 'supports' => array( 'autoRegister' => true ), ) );} );What you get: a block with no JavaScript and no build, free, in core. The editor shows a server-rendered preview and builds a Settings panel from the attributes: a text field for a string, a number field, an on/off setting, and a select for a string with an enum.
Where it stops, as of 7.0: the preview can't be edited on the canvas, so settings are changed in the sidebar. There are no image, link or rich text fields, no InnerBlocks and no validation. WordPress's own dev note says the feature "isn't meant to replace the existing client-side paradigm". For a notice, a latest-posts list or a contact line, it's the simplest way to make a block. More on PHP-only blocks.
Way three: fields and a template, with GCB
Gutenberg Control Blocks is a paid plugin for the blocks in between: too rich for PHP-only registration, not worth a React build each. A block is a folder in your theme's blocks/ folder with three plain files. You don't register it: there's no register_block_type() call and nothing in functions.php, because GCB finds the folder and registers the block itself.
{ "apiVersion": 3, "name": "gcb/notice", "title": "Notice", "category": "widgets", "icon": "megaphone"}{ "controls": [ { "id": "c_title", "type": "text", "label": "Title", "attributeKey": "title", "validation": { "required": true, "maxLength": 60 } }, { "id": "c_photo", "type": "image", "label": "Photo", "attributeKey": "photo" } ]}<div <?php echo get_block_wrapper_attributes( array( 'class' => 'notice' ) ); ?>> <p data-gcb-field="title" data-gcb-field-type="text"><?php echo esc_html( $attributes['title'] ?? '' ); ?></p></div>What you get: no JavaScript in your theme and no build. The editor draws the block from the same render.php the page uses, so what your client edits is 1:1 with the front end. Anything marked data-gcb-field is edited where it sits on the page. There are 42 field types, including image, gallery, link, rich text and repeater, several InnerBlocks areas in one block, and rules such as required fields that stop a page saving until they pass.
What it costs: GCB is a paid plugin, from $99 a year, and it needs WordPress 6.8 or later. If you stop using it, its Eject page turns your blocks into a standalone plugin of plain WordPress blocks.
If your front end is React, Vue or another framework, the template can live there as a component in place of render.php, and the editor asks your front end to draw the block. How to build a block with GCB walks through both.
Side by side
| React | PHP only (WP 7.0) | GCB | |
|---|---|---|---|
| Build step | npm build | None | None |
| Editor code you write | All of it | None | None |
| Edit on the canvas | If you code it | No | Yes: text, images, links |
| Field types | Build each one | Text, number, on/off, select | 42 |
| InnerBlocks | One area | Not supported | Several areas per block |
| Validation | Write it yourself | None | Built in, checked on the server |
| Price | Free | Free, in core | From $99 a year |
Which to use
- A block with a handful of plain settings, edited now and then: PHP-only registration. It's built in.
- A block your client edits often, with pictures, links, lists or content areas: GCB.
- A block that is really an app: React with
@wordpress/create-block.
Next
To see finished blocks with every file in full, start with the Hero, the Team grid or the Store locator. The rest of the examples are there to download.