Discover in this tutorial how to limit the WordPress editor blocks that are displayed in a Custom Post Type (CPT) by code.
WordPress block editor comes with more than 30 native blocks, which provides great versatility when creating content. You can even extend the number of blocks by installing extra plugins.
However, this has a disadvantage: such a large number of blocks can be overwhelming for your customers.
For example, in a Custom Post Type course, you may not need more than 4 blocks to be able to generate them. And in that case, why have the other 30 “bothering”?
The good thing is that the block editor allows you to restrict the blocks you want to display in each CPT.
Are you interested? Well, keep reading. 🙂
Snippet to limit editor blocks in a Custom Post Type
Add this fragment in functions.php:
With this code you get the CPT “Course” entries to show only the following blocks:
Of course, I invite you to modify it to include more blocks or to affect other CPTs according to your needs.
As the above snippet is not specific to Genesis, you can use it for any WordPress child theme.
Now you know that if you only need a few types of blocks to create the post for certain CPTs, you can restrict them using these lines.
This is a good example of “less is more”, one of those little details that make your customer’s life easier.
If you want information on how to adapt the Genesis child themes to the WordPress block editor, check the tutorial with all the optimizations you need to do to make sure it is compatible with it.
Any questions? Let me know in the comments.
And if you want to give me any suggestion for future tutorials, leave it in the contact form. Advantages of being a subscriber. 😉