How to Disable Gutenberg for Custom Post Types (WordPress)

Sometimes it is necessary in WordPress to disable the Gutenberg editor for a custom post type. I try to keep Gutenberg enabled whenever possible, but there are cases where a post type needs to be custom field driven or a simple interface for my users. The examples below will show how to disable Gutenberg for a specific post type while leaving another alone.

Gutenberg Disabling Examples

The following snippets of code can be used in your functions.php or plugin file to disable Gutenberg on certain post types while leaving it active on others.

Example: Disabling Gutenberg for Posts

function my_disable_gutenberg_posts( $current_status, $post_type ) {

    // Disabled post types
    $disabled_post_types = array( 'post' );

    // Change $can_edit to false for any post types in the disabled post types array
    if ( in_array( $post_type, $disabled_post_types, true ) ) {
        $current_status = false;
    }

    return $current_status;
}
add_filter( 'use_block_editor_for_post_type', 'my_disable_gutenberg_posts', 10, 2 );

Example: Disabling Gutenberg for Custom Post Types

This PHP snippet will disable two post types (book and movie).

function my_disable_gutenberg( $current_status, $post_type ) {

    // Disabled post types
    $disabled_post_types = array( 'book', 'movie' );

    // Change $can_edit to false for any post types in the disabled post types array
    if ( in_array( $post_type, $disabled_post_types, true ) ) {
        $current_status = false;
    }

    return $current_status;
}
add_filter( 'use_block_editor_for_post_type', 'my_disable_gutenberg', 10, 2 );

Disabling Gutenberg Completely

If you need to disable Gutenberg on your site completely, I recommend installing the Classic Editor plugin over adding your own code to do so. If you insist on a code based solution, you can use the following code. I do not recommend doing this.

function my_disable_gutenberg_completely( $current_status, $post_type ) {
    return false;
}
add_filter( 'use_block_editor_for_post_type', 'my_disable_gutenberg_completely', 10, 2 );