Support » Plugin: Gutenberg » Enable Gutenberg with filter does not work

  • Resolved DavidPeralvarez

    (@davidperalvarez)


    Hi there!

    When I try to enable Gutenberg editor for a certain CPT that has “show_in_rest” parameter set to false using the filter “gutenberg_can_edit_post_type” like this:

    // Enable or disable Gutenberg in CPT
    function twentyfifteen_can_edit_post_type( $can_edit, $post_type ){
    
    	if( "service" == $post_type ){
    		return true;
    	}
    
    	return $can_edit;
    
    }
    
    add_filter( 'gutenberg_can_edit_post_type', 'twentyfifteen_can_edit_post_type', 10, 2 );

    It shows a blank screen when I load the editor.

    The CPT is defined in a third party plugin, so I don’t want to modify the “show_in_rest” parameter manually.

    Should I use instead the “register_post_type” function to update my CPT inside the theme?

    Anyone can help me? Thank you very much!

Viewing 1 replies (of 1 total)
  • Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    Gutenberg uses the REST API, so if you have that disabled for that post type, then no amount of filtering is going to work for it. The post type must be enabled in REST to work with Gutenberg.

Viewing 1 replies (of 1 total)
  • The topic ‘Enable Gutenberg with filter does not work’ is closed to new replies.