WordPress

Enable Gutenberg Editor in Custom Post Types

In this tutorial, we will see how to enable the new Gutenberg editor in our Custom Post Types.

First we must go to the file where it belongs to our Custom Post Type, in the type path:

Domain.com -> wp-content -> plugins -> CPT> custom_post_type.php

Edit the php file, which will have a similar similarity to the following Custom Post Type of Courses:

add_action ('init', 'create_a_cpt'); 
function create_a_cpt () { 
     $ args = array ( 
     'public' => true, 
     'label' => 'Courses', 
     ' menu_icon '=>' dashicons-info ', 
     ' has_archive '=> true, 
     ' capability_type '=>' post ', 
     ' menu_position '=> 2, 
     ' show_in_rest '=> true, 
); 
register_post_type ('courses', $ args); 
}

Well, we must add the argument of:

'show_in_rest' => true,

editor_gutenberg_custom_post_types_wordpress

This will make the classic editor of all life in WordPress, is transformed into the new editor of Gutenberg, as we have in the Posts of our site.

Related posts

20 Best Membership Plugins for WordPress in 2019

WPITECH

5 Best RSS Feed Plugins for WordPress

WPITECH

How To Use WP_Query to Create Pagination in WordPress

WPITECH