WordPress 7.0 Lets You Build Gutenberg Blocks with Pure PHP
One of the most exciting developer features landing in WordPress 7.0 (releasing April 9, 2026) is PHP-Only Block Registration. For the first time, developers can create fully functional Gutenberg blocks using nothing but PHP, no JavaScript, no build tools, no block.json file required. The community reaction has been overwhelmingly positive, with many calling it the first block-editor-related good news since Gutenberg was first implemented.
In this guide, we walk you through exactly how to use the new autoRegister flag to build your first PHP-only WordPress block.
What Is PHP-Only Block Registration?
WordPress 7.0 introduces a new autoRegister support flag in register_block_type(). When set to true, WordPress automatically registers the block in the editor without any JavaScript, and auto-generates Inspector Controls sidebar UI for your block attributes. It is designed for server-side rendered blocks that do not need complex interactivity.
Step 1: Register Your Block with autoRegister
Use register_block_type() with the autoRegister support flag and a render_callback:
function my_plugin_register_php_blocks() {
register_block_type(
'my-plugin/announcement',
array(
'title' => __( 'Announcement', 'my-plugin' ),
'attributes' => array(
'message' => array(
'label' => __( 'Message', 'my-plugin' ),
'type' => 'string',
'default' => 'Enter your announcement here.',
),
'style' => array(
'label' => __( 'Style', 'my-plugin' ),
'type' => 'string',
'enum' => array( 'info', 'warning', 'success' ),
'default' => 'info',
),
'visible' => array(
'label' => __( 'Visible', 'my-plugin' ),
'type' => 'boolean',
'default' => true,
),
),
'render_callback' => function ( $attributes ) {
if ( ! $attributes['visible'] ) {
return '';
}
return sprintf(
'<div class="announcement announcement--%s"><p>%s</p></div>',
esc_attr( $attributes['style'] ),
esc_html( $attributes['message'] )
);
},
'supports' => array(
'autoRegister' => true,
),
)
);
}
add_action( 'init', 'my_plugin_register_php_blocks' );
Step 2: Understand Supported Attribute Types
The autoRegister feature currently supports these attribute types, each of which auto-generates a corresponding editor control:
- string – Generates a text input field
- string with enum – Generates a dropdown select control
- integer / number – Generates a number input
- boolean – Generates a toggle/checkbox control
Each attribute should include a label property for the Inspector Controls sidebar UI.
Step 3: Add Your Block to a Plugin or Theme
Place your block registration code inside your plugin’s main PHP file or your theme’s functions.php. The block will automatically appear in the Gutenberg block inserter once registered, no JavaScript build step needed.
Step 4: Style Your Block
Add CSS to your plugin or theme to style the block output. Since the block is server-side rendered, styles are applied on the frontend as normal:
.announcement {
padding: 1rem 1.5rem;
border-radius: 6px;
margin: 1rem 0;
}
.announcement--info { background: #e8f4fd; border-left: 4px solid #2196F3; }
.announcement--warning { background: #fff8e1; border-left: 4px solid #FFC107; }
.announcement--success { background: #e8f5e9; border-left: 4px solid #4CAF50; }
Step 5: Test in the Block Editor
After activating your plugin or theme, open any post or page in the WordPress editor. Search for your block name in the inserter. It will appear just like any other block. The Inspector Controls panel on the right will show auto-generated controls for all your defined attributes.
Key Limitations to Know
- No inner blocks support – PHP-only blocks cannot contain other blocks as children yet
- No save function – All rendering is server-side via render_callback
- No sourced attributes – Attributes must be stored in block JSON, not serialized as HTML
- Limited attribute types – Only string, integer, number, and boolean are currently supported
Why This Matters for WordPress Developers
PHP-Only Block Registration dramatically lowers the barrier to creating custom Gutenberg blocks. Previously, even a simple block required setting up a JavaScript build environment with Node.js, npm, and webpack or Vite. Now, PHP developers can build blocks using the language they already know, making block development accessible to a much wider audience and perfect for classic themes, server-driven workflows, and simple custom blocks.
Key Takeaway: WordPress 7.0’s autoRegister feature is a game-changer for PHP developers. While it has current limitations, it opens the door to rapid block development without JavaScript complexity. Expect this API to expand in future WordPress releases as the Fields API and block fields mature.
Hashtags: #WordPress #WordPress7 #GutenbergBlocks #PHPDevelopment #WebDevelopment #WordPressDev #BlockEditor #PHP
Resources: