When you add "show_in_rest" argument when registering a custom post type, Gutenberg editor is automatically enabled for that post type.
What if developer wants to enable rest api for the custom post type but doesn't want to have Gutenberg editor enabled for that one? For instace, if I have (let's say), discount codes custom post type which I want to have enabled in the REST API but it's nonsense to have a fancy Gutenberg editor because editor is not needed at all.
Wouldn't be a better solution to have one more argument, let's say, "use_gutenberg_editor" which will show a Gutenberg editor (only in that case)? That one could enable show_in_rest automatically as well since rest is needed for Gutenberg blocks to work.
Thanks!
Gutenberg becomes the default editor, so it should be enabled by default.
You can use the gutenberg_can_edit_post_type filter to disable Gutenberg per post type:
Example: https://gist.github.com/uptimizt/b99ef36aabab1ff641414e593e73d040
OK, thanks for the answer. But I think instead of doing this way would be more convenient to have just one argument but maybe it's just me.
One question, Gutenberg will become default editor for ALL CUSTOM POST TYPES by default? or only for those post types which have show_in_rest argument?
Gutenberg needs show_in_rest in the CPT to be enabled, so if you don't have the parameter it isn't enabled.
If you don't need an editor in your CPT at all, you can remove editor from the supports array.
I know that, I just wanted to hear what is the plan for the custom post types. Thanks
Great discussion, good to have this worked out. It sounds like the questions were resolved (?) so I'm closing this! ✨
For anybody arriving here via a web search, the filter name in WordPress 5.0 is use_block_editor_for_post_type instead of gutenberg_can_edit_post_type.
(But the gutenberg_can_edit_post_type still exists in the plugin so both need to be supported... 😒 )
Most helpful comment
For anybody arriving here via a web search, the filter name in WordPress 5.0 is
use_block_editor_for_post_typeinstead ofgutenberg_can_edit_post_type.