Creating Custom Blocks with Only PHP: How WordPress 7.0 Made It This Simple
Previous custom block environment: Created with the Lazy Blocks plugin
When I wanted to create original blocks in WordPress, I used to use a plugin called Lazy Blocks.
It is a very convenient plugin that allows you to create custom blocks just by defining input fields in a GUI. I valued it because it significantly reduces the amount of code compared to standard custom block creation.
However, there was one thing that always bothered me...
The dependency issue where the Lazy Blocks plugin itself is required when moving blocks to another WordPress site. Considering distribution and migration, I wanted to avoid dependency on plugins if possible. Just as I was thinking that, the WordPress 7.0 update arrived.
WordPress 7.0 made creating custom blocks even easier
Starting with WordPress 7.0, an official mechanism has been added to create custom blocks using only PHP code.
(Reference: PHP-only block registration – Make WordPress Core)
Previously, creating custom blocks required JavaScript skills in addition to PHP, but this update has made it much simpler. Since the block configuration options are somewhat limited, it is harder to get bogged down in detailed UI creation.
Things that cannot be done at the moment
Since it is still a developing feature, there are some things that cannot be done.
Does not support image or file uploads
It is still difficult to finely layout input areas
Compared to Lazy Blocks, there are still fewer configurable items
However, this is only for now. While looking forward to future updates, I decided to start by recreating the blocks I currently have.
I tried recreating blocks made with Lazy Blocks using the official method
What I recreated this time is a custom block for entering volleyball match results.
With the help of Claude Code, I reproduced the same functionality as the one created with Lazy Blocks using the new method.
Operation screen/video of the old block (Lazy Blocks version)
Editing screen (block editor) of the new block (PHP registration version)

Comparison of Old and New Blocks
External Plugins
Lazy Blocks Version: Requires Lazy Blocks plugin
New Block: No plugin required
Set Count Specification
Lazy Blocks Version: Available
New Block: Discontinued
Category/Gender Classification
Lazy Blocks Version: Manual selection required every time
New Block: Automatically determined from post type (manual specification also possible)
Main Changes
Discontinued the specification of set countsPreviously, the specification required manual entry of 'how many sets were played,' but since it was unnecessary in actual operation, it was removed. The input fields have become simpler.
Category and gender classification are now automatically determined from the post typeSince the content is almost always determined by the post type, I eliminated the hassle of selecting them every time.
Although I created this block for volleyball, it seems it could also be used for badminton or table tennis.
Volleyball matches are basically played in 3 or 5 sets.
In rebuilding it this time, I removed the limit on the number of sets, making it possible to support matches with 5 or more sets in other sports as well.
Thoughts on the Experience
Lazy Blocks is a convenient plugin that allows you to create blocks easily, but I have always been concerned about the fact that 'the plugin is also required in the user's environment.' With this new mechanism, that concern has been completely resolved.
Since image uploads and free-form layouts are not yet possible, Lazy Blocks is still superior in terms of functionality. However, for simple blocks, the official method is sufficient, and it feels better not to have unnecessary dependencies.
Since this feature is still in development, I would like to try it out with every update.
#WordPress #WordPress7.0 #Gutenberg #CustomBlocks #LazyBlocks #ClaudeCode #PersonalDevelopment #Volleyball #Badminton #TableTennis
