By default, a WordPress custom post type does not use the Gutenberg editor. Why? In this quick tip, I’ll walk you through the why and show you how to enable the Gutenberg editor for your custom post types. Don’t worry. It’s literally one configuration parameter.

Gutenberg uses the REST API. But by default, the REST API parameter turned off when you register a custom post type. Therefore, you need to intentionally turn it on in your code. Let me show you how.

The Code

Here is a link to the Books plugin gist if you want to work along with me.

In the configuration arguments where you register the custom post type, add the following configuration parameter:

'show_in_rest'       => true, // To use Gutenberg editor.

For example, let’s say you are registering a Book post type. The registration arguments might be:

function sitegrows_register_book_post_type() {
    $labels = [
        // left out for brevity.
    $args = [
        'labels'             => $labels,
        'public'             => true,
        'publicly_queryable' => true,
        'show_ui'            => true,
        'show_in_menu'       => true,
        'show_in_rest'       => true, // To use Gutenberg editor.
        'query_var'          => true,
        'rewrite'            => [ 'slug' => 'book' ],
        'has_archive'        => true,
        'hierarchical'       => false,
        'menu_position'      => null,
    register_post_type( 'book', $args );

Here is a quick tip to remove the piece of code added by WordPress 4.4 in the header of your pages about wp-embed.

wp-embed.js is a script added by wordpress
It’s super easy to embed videos, images, tweets, audio, and other content into your WordPress site. This feature was added in WordPress 2.9″

That’s the code WordPress adds in your page:

function sitegrows_deregister_scripts(){
	wp_deregister_script( 'wp-embed' );
add_action( 'wp_footer', 'sitegrows_deregister_scripts' );