Do you love wordplay? I hope so. Metabloxes is not a real thing. But maybe it should be as a way to explain using Gutenberg blocks designed to manage data and replace traditional PHP metaboxes. In this article focused on WordPress plugin development we cover the topic of how to replace metaboxes with Gutenberg blocks that save metadata, or as we’re calling them at SaberWP – metabloxes. It’s catchy isn’t it? Maybe we’ll turn it into a library… get you’re metabloxes here.
The fundamental concept we’re covering here is simple. You have a plugin that creates a custom post type. It has meta data. You collect metadata with metabox. Life is simple, life is good. But now Gutenberg comes along and makes your life 5,000% more complexified. So now if you keep using metaboxes they will look second-rate and be pushed to the bottom of the screen. The good news is all you have to do is change everything.
It goes without saying that if you don’t know React, you’re no longer invited to the party. What party? The complexified WP dev track where you still get paid less because you know PHP, but you also get to be an expert at React JS but without the salary of a full React dev. That’s right, you got Gutenberged! Now go study React!
Overview of the Process of Using Gutenberg Meta Blocks
- Adapt your CPT registration (register_post_type() arguments) to utilize the “template” and “template_lock” arguments. This is the key to presenting a consistent editing interface with your data collection blocks shown by default in the editor. We’ll detail how to use these arguments later or you can view them in the register_post_type() documentation.