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
Featured products query WooCommerce
11. 4. 2021 in
If you are using your own queries for WooCommerce stores, for example in Oxygen builder’s custom code block then you may need query for featured products. You can use the query I am using inside my product sliders :-).
Read More
Aleš Sýkora wrote
How to use Infinite Scroll in Repeater element of Oxygen Builder
If you want to use the “Load more” button when using repeater, you can do that with .JS library called “Infinite Scroll“. Load Infinite Scroll script from CDN (I am using Advanced Scripts again). For a speed purposes – use conditions to make it load only on pages where you need to use it. Current […]
Read More
Aleš Sýkora wrote
Change GDPR field response data in Fluent Forms
15. 4. 2021 in
If you want to change the “Accepted” to something else, use the first snippet and change the $response variable. If you want to change the Terms and Condition and GDPR field response, use this code:
Read More
magnifiercross linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram