Aleš Sýkora wrote

Enable Gutenberg for Custom post type

12. 4. 2021 in

If you create Custom post type in WordPress and want to use Gutenberg editor instead of classic editor, you need to add this in your code:

    'show_in_rest' => true,
       'supports' => array('editor')

Here is complete example of CPT supporting Gutenberg editor.

// Register Custom Post Type Career
function as_cpt_career() {

	$labels = array(
		'name'                  => _x( 'career', 'Post Type General Name', 'text_domain' ),
		'singular_name'         => _x( 'career', 'Post Type Singular Name', 'text_domain' ),
		'menu_name'             => __( 'career', 'text_domain' ),
		'name_admin_bar'        => __( 'career', 'text_domain' ),
	$args = array(
		'label'                 => __( 'career', 'text_domain' ),
		'description'           => __( 'career', 'text_domain' ),
		'labels'                => $labels,
		'show_in_rest'			=> true,
		'supports'              => array( 'title', 'editor', 'revisions', 'custom-fields' ),
		'hierarchical'          => false,
		'public'                => true,
		'show_ui'               => true,
		'show_in_menu'          => true,
		'menu_position'         => 5,
		'show_in_admin_bar'     => true,
		'show_in_nav_menus'     => true,
		'can_export'            => true,
		'has_archive'           => false,
		'exclude_from_search'   => true,
		'publicly_queryable'    => false,
		'capability_type'       => 'page',
	register_post_type( 'career', $args );

add_action( 'init', 'as_cpt_career', 0 );

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.

More from category
Aleš Sýkora wrote
Custom markup for WordPress Custom Post types
26. 9. 2019 in
Learn how to add markup with JSON-ld and WordPress and create your own unique plugin.
Read More
Aleš Sýkora wrote
Comments Shortcode for Content Templates
11. 11. 2019 in
Display comments section whetever you want.
Read More
Aleš Sýkora wrote
Translate labels in Iconic Delivery Slots
21. 1. 2021 in
If you need to change labels of fields added by Iconic Delivery Slots to WooCommerce checkout, use this snippet:
Read More
magnifiercross linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram