Getting Gutenberg to see custom post types & taxonomies
written by: Jeff McNearGetting Gutenberg to see custom post types & taxonomies
If you use GenerateWP you may have noticed that there is now a “rest API” tab in the custom post type and custom taxonomy generators. If you don’t uses GenerateWP yet go ahead and register for the site as you can still use the generators for free.


By default the generator will not add rest API support and so a custom post type will use the classic editor, and a taxonomy will not show in Gutenberg – meaning the “args array” for the post type would look like this
$args = array(
'label' => __( 'Grill Product', 'text_domain' ),
'description' => __( 'Post Type Description', 'text_domain' ),
'labels' => $labels,
'supports' => array( 'title', 'editor', 'thumbnail', 'comments', 'revisions', 'post-formats', 'excerpt', 'author' ),
'taxonomies' => array( 'grill_function', 'grill_fuel' , 'grill_burner'),
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 7,
'menu_icon' => 'dashicons-dashboard',
'show_in_admin_bar' => true,
'show_in_nav_menus' => true,
'can_export' => true,
'has_archive' => true,
'exclude_from_search' => false,
'publicly_queryable' => true,
'capability_type' => 'post',
);
register_post_type( 'grill_products_type', $args );
but changing the option to yes will change the array to this
$args = array(
'label' => __( 'Grill Product', 'text_domain' ),
'description' => __( 'Post Type Description', 'text_domain' ),
'labels' => $labels,
'supports' => array( 'title', 'editor', 'thumbnail', 'comments', 'revisions', 'post-formats', 'excerpt', 'author' ),
'taxonomies' => array( 'grill_function', 'grill_fuel' , 'grill_burner'),
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 7,
'menu_icon' => 'dashicons-dashboard',
'show_in_admin_bar' => true,
'show_in_nav_menus' => true,
'can_export' => true,
'has_archive' => true,
'exclude_from_search' => false,
'publicly_queryable' => true,
'capability_type' => 'post',
'show_in_rest' => true,
);
register_post_type( 'grill_products_type', $args );
adding the line of
'show_in_rest' => true,
…. and it is the same case with taxonomies where this:
$args = array(
'labels' => $labels,
'hierarchical' => true,
'public' => true,
'show_ui' => true,
'show_admin_column' => true,
'show_in_nav_menus' => true,
'show_tagcloud' => true,
);
would be changed to something like this
$args = array(
'labels' => $labels,
'hierarchical' => true,
'public' => true,
'show_ui' => true,
'show_admin_column' => true,
'show_in_nav_menus' => true,
'show_in_rest' => true,
'show_tagcloud' => true,
);