How to use Gutenberg with WordPress custom post types
Working with the Gutenberg editor has been quite the journey. We Recently ran into a scenario where we needed Gutenberg to work when using the WordPress custom post type.
How the editor works
Gutenberg with custom post types
To add support for custom post types you must:
- add support for the editor.
- add the show_in_rest key and set it to true via your custom post type.
The code below is usually defined in the array arguments in your custom post type file. In the same array that your support key is defined, add another key, show_in_rest and set it to true. See the sample code below.
Now when editing your custom post type, Gutenberg should appear and work as expected.