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

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.


Content Squad

We are the content squad. Dedicated to bringing you news about WordPress and our themeshop.

4 thoughts on “How to use Gutenberg with WordPress custom post types

  1. Did you ever tested the columns block in a custom post type?
    It seems output is screwed up, ’cause it messes tag with the tag of each column… DAMN Gutenberg!

    …Or it happens to me??? 🙁

Leave a Reply

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