GCBGutenberg
Control Blocks
v1.3.3
Buy

Custom Gutenberg blocks without React

Build a block with block.json, a JSON list of fields and a PHP template. No React, no npm, no build step.

WordPress's own way to make a block is block.json plus React. You write an edit.js for the editor, a save function or a PHP render for the page, and run an npm build every time you change either. For a block that is a heading, a photo and a button, that's a lot of tooling, and it means two copies of the markup to keep in step.

Gutenberg Control Blocks (GCB) takes React out of it. A block is a folder in your theme with three plain files, and the PHP template is used both in the editor and on the page.

The three files

block.json is WordPress's standard block metadata, the same file a core block has:

block.json
{  "apiVersion": 3,  "name": "gcb/solace-badge",  "title": "Solace badge",  "category": "widgets",  "icon": "tag"}

block.fields.json lists the block's fields. Each has a type, a label, and the attribute it saves to:

block.fields.json
{  "controls": [    { "id": "c_label", "type": "text", "label": "Label",      "attributeKey": "label", "default": "New in" }  ]}

render.php is the template. It reads the field values from $attributes, just like a core block's PHP render:

render.php
<?php $label = esc_html($attributes['label'] ?? ''); ?><div <?php echo get_block_wrapper_attributes(['class' => 'sol-badge']); ?>>  <span data-gcb-field="label" data-gcb-field-type="text"><?php echo $label; ?></span></div>

Save the files and refresh the editor. The block is in the inserter. Nothing to compile, no node_modules, no build to keep running.

What the editor gets

  • The real design. The editor shows your template's output, so what your client edits looks like the page.
  • Editing on the page. The data-gcb-field attribute in the template makes that span editable where it sits: your client clicks the badge and types. Images, links and headings work the same way.
  • Fields in the sidebar. Everything else in block.fields.json appears in the block's sidebar, grouped into panels.
  • Typed values. A field is one of 42 types, from text and images to colours from your theme, repeaters, layouts and dates. Each saves a value of a known shape, and validation rules stop a page saving until a required field is filled.

How it compares with the React way

block.json + ReactGCB
Files per blockblock.json, edit.js, a save or render, stylesblock.json, block.fields.json, render.php
Build stepnpm and webpackNone
Editor markupWritten separately in ReactThe same template as the page
FieldsBuilt from components by handDeclared in JSON
The resultA standard WordPress blockA standard WordPress block, registered from block.json

What about WordPress 7.0's PHP-only blocks? WordPress 7.0 added a core way to register a block from PHP alone: a render callback plus autoRegister in its supports, with no JavaScript or build. It's a good fit for simple blocks. Its sidebar is generated only for text, number, on/off and select settings, though, the preview can't be edited on the canvas, and it has no InnerBlocks. More on PHP-only blocks. GCB adds the rest: 42 field types, editing on the page, repeaters, multiple InnerBlocks areas, validation and your theme's presets.

React is still the right tool for a block that is really an app, like a calculator or a booking form. For the blocks a theme is made of (heroes, cards, features, galleries, testimonials), a template and a list of fields is enough.

You're not locked in

Your blocks are registered as ordinary WordPress blocks, and the field values are saved as ordinary block attributes. If you stop using GCB, the Eject page turns your blocks into a standalone plugin of plain WordPress blocks, with their fields and editor bundled in.

Try it

The Quickstart walks through a first block, and the field reference covers every field type. You can also try a real block in your browser before you buy.

Build anything in the block editor

Every licence includes all features and a year of updates and support.

Buy GCB from $8.25 a month See pricing