Disable block editor for specific post types in WordPress

Disable the block editor for specific post types

The block editor is a good fit for articles and landing pages, but not for every post type. Testimonials, team members or events often consist of a few structured fields (ACF or meta boxes) and a short text, and for editors who fill in dozens of them a day, the block interface is just extra clicks. WordPress can use the classic editor for some post types and the block editor for others, without the Classic Editor plugin.

Problem: Simple custom post types open in the block editor, while editors only need the title, a short text and the fields below.

Solution: Return false from the use_block_editor_for_post_type filter for those post types. For single posts (one page that is built with a page builder, for example), the use_block_editor_for_post filter decides per post.

Per post type

<?php
add_filter( 'use_block_editor_for_post_type', 'ha_classic_editor_for_post_types', 10, 2 );

function ha_classic_editor_for_post_types( $use_block_editor, $post_type ) {
    $classic = array( 'testimonial', 'team_member', 'event' );

    if ( in_array( $post_type, $classic, true ) ) {
        return false;
    }

    return $use_block_editor;
}

These post types now open in the classic editor; posts, pages and all other types keep the block editor.

Per post

<?php
add_filter( 'use_block_editor_for_post', function ( $use_block_editor, $post ) {
    // The landing page built with a page builder: classic editor
    if ( 'page' === $post->post_type && 'landing' === $post->post_name ) {
        return false;
    }

    // Pages with a certain template
    if ( 'templates/form-page.php' === get_page_template_slug( $post ) ) {
        return false;
    }

    return $use_block_editor;
}, 10, 2 );

Without show_in_rest

A post type registered without 'show_in_rest' => true never uses the block editor, because the block editor loads and saves posts through the REST API. That is why older custom post types open in the classic editor by default. Disabling the block editor with the filter is the better way when the post type should still be available in the REST API, for a headless front end or an app.

Removing the block styles on the front end

The classic editor does not remove the block library CSS that WordPress loads on the front end. If no page of the site uses blocks, it can be removed too:

<?php
add_action( 'wp_enqueue_scripts', function () {
    wp_dequeue_style( 'wp-block-library' );
}, 100 );

Do this only when really no content uses blocks: otherwise those blocks lose their styling.

NOTE: Content written in the classic editor is stored without block comments. When a post type is switched back to the block editor later, existing posts open as one “Classic” block and can be converted with “Convert to blocks”; nothing is lost.