Enable Gutenberg on Custom Post Types

Gutenberg is the new content editor in WordPress. But it’s not automatically applied to custom post types, they still use the classic editor. It might be automatically applied in the future but for now a slight code adjustment is needed.

Here’s an example:

All we need to do is set show_in_rest to true, like this:

Basically what that does is enables the REST API for the custom post type, which is needed for the post add/edit page and Gutenberg to function.

Tags: ,
Previous Post
wordpress-get-related-posts
Tutorials

Simplest Method of Getting Related Posts

Next Post
add-custom-class-body-wordpress
WPDev101

Adding Custom Classes to the Body Tag in WordPress

Comments

    • Alvina
    • May 27, 2019
    Reply

    I am having an unknown error while implementing the code to enable gutenberg. I have also followed this tutorial https://www.cloudways.com/blog/gutenberg-wordpress-custom-post-type/ but I am having the same issues an error. Can you help me to resolve this issue?

      • BobaWebDev
      • May 27, 2019
      Reply

      When does the error show up ( all pages, specific page or specific action)? Do the server logs show anything? What’s the exact code you have for the registration of the custom post type?

    • Sebastian
    • August 18, 2019
    Reply

    Yes, so I have the same problem. The general problem is that when I add this:

    ‘show_in_rest’ => true,

    to the custom post, once it has been published, link returns 404.

    Also when this code was added to the custom page create by User Registration & User Profile – Profile Builder, it causes redirect to malfunction.

    Same with the code you have shared in your post – gutenberg is there, but post is not found.

    Would it be possible for you to share a complete code maybe?

    One thing for sure – gutenberg and custom post types do not mix 🙂

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.