Skip to main content
PHPwordpressbeginner

Disable Gutenberg Block Editor

Disable the Gutenberg editor and use the Classic Editor instead

Faisal Yaqoob
#gutenberg#classic-editor#wordpress#admin
Share this snippet:

Code

php
1// Method 1: Disable Gutenberg completely
2add_filter('use_block_editor_for_post', '__return_false', 10);
3
4// Method 2: Disable for specific post types only
5function disable_gutenberg_for_post_types($can_edit, $post_type) {
6 $disabled_post_types = array('page', 'custom_post_type');
7
8 if (in_array($post_type, $disabled_post_types)) {
9 return false;
10 }
11
12 return $can_edit;
13}
14add_filter('use_block_editor_for_post_type', 'disable_gutenberg_for_post_types', 10, 2);
15
16// Method 3: Disable for users with specific roles
17function disable_gutenberg_for_roles($can_edit, $post) {
18 $current_user = wp_get_current_user();
19 $disabled_roles = array('contributor', 'author');
20
21 if (array_intersect($disabled_roles, $current_user->roles)) {
22 return false;
23 }
24
25 return $can_edit;
26}
27add_filter('use_block_editor_for_post', 'disable_gutenberg_for_roles', 10, 2);
28
29// Bonus: Remove Gutenberg CSS from frontend
30function remove_gutenberg_css() {
31 wp_dequeue_style('wp-block-library');
32 wp_dequeue_style('wp-block-library-theme');
33 wp_dequeue_style('wc-block-style'); // WooCommerce blocks
34 wp_dequeue_style('global-styles'); // Theme.json
35}
36add_action('wp_enqueue_scripts', 'remove_gutenberg_css', 100);

Disable Gutenberg Block Editor

This snippet provides different methods to disable the Gutenberg block editor in WordPress and revert to the Classic Editor.

// Method 1: Disable Gutenberg completely
add_filter('use_block_editor_for_post', '__return_false', 10);

// Method 2: Disable for specific post types only
function disable_gutenberg_for_post_types($can_edit, $post_type) {
    $disabled_post_types = array('page', 'custom_post_type');

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

    return $can_edit;
}
add_filter('use_block_editor_for_post_type', 'disable_gutenberg_for_post_types', 10, 2);

// Method 3: Disable for users with specific roles
function disable_gutenberg_for_roles($can_edit, $post) {
    $current_user = wp_get_current_user();
    $disabled_roles = array('contributor', 'author');

    if (array_intersect($disabled_roles, $current_user->roles)) {
        return false;
    }

    return $can_edit;
}
add_filter('use_block_editor_for_post', 'disable_gutenberg_for_roles', 10, 2);

// Bonus: Remove Gutenberg CSS from frontend
function remove_gutenberg_css() {
    wp_dequeue_style('wp-block-library');
    wp_dequeue_style('wp-block-library-theme');
    wp_dequeue_style('wc-block-style'); // WooCommerce blocks
    wp_dequeue_style('global-styles'); // Theme.json
}
add_action('wp_enqueue_scripts', 'remove_gutenberg_css', 100);

When to Use This

  • Legacy Sites: Sites that were built with Classic Editor and don't need block editor features
  • Client Preference: Some clients prefer the simpler Classic Editor interface
  • Custom Meta Boxes: When using extensive custom meta boxes that don't work well with Gutenberg
  • Performance: Removing unused Gutenberg CSS can slightly improve page load times

Alternative

Instead of using code, you can install the official Classic Editor plugin which is maintained by WordPress core team.