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

The primary editor is mainly built using Javascript thus to make any calls or changes to WordPress, Gutenberg must utilize the REST API for it to make updates and changes.

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.

Author

Leave a Reply

Your email address will not be published. Required fields are marked *