Puan
28,728
Çözümler
0
- Konum
- Freanchey
- Mesajlar
- 3,047
- Katılım
- 2 Eki 2026
- Tepkime puanı
- 3,565
- Puan
- 28,728
- Web sitesi
- glomaxgpt.com
You want to build a custom WordPress block. But you don’t want to learn React, manage a build pipeline, or deal with NPM packages.
Seven and half years after blocks arrived in Core, WordPress introduces a way to build blocks without any of these things. All you need is PHP.
But was the long wait worth it?
A radically simplified block building experience
A traditional WordPress block needs to be registered twice. Once in PHP, and once in JavaScript.
But WordPress 7.0 introduces a new and streamlined approach, allowing you to register a block using only PHP.
Registering a block using only PHP
Let’s use this feature to build a Hello World Block:
function css_tricks_hello_world_block() {
'render_callback' => function () {
);
}
add_action('init', 'css_tricks_hello_world_block');
The block is fully functional in the block editor, and fits right in with all the other blocks:
Seven and half years after blocks arrived in Core, WordPress introduces a way to build blocks without any of these things. All you need is PHP.
But was the long wait worth it?
A radically simplified block building experience
A traditional WordPress block needs to be registered twice. Once in PHP, and once in JavaScript.
But WordPress 7.0 introduces a new and streamlined approach, allowing you to register a block using only PHP.
Registering a block using only PHP
Let’s use this feature to build a Hello World Block:
function css_tricks_hello_world_block() {
'render_callback' => function () {
);
}
add_action('init', 'css_tricks_hello_world_block');
The block is fully functional in the block editor, and fits right in with all the other blocks:
