How to revert to the WordPress Classic Editor (original editor) – disable Gutenberg Block Editor completely or for a post type

In WordPress version 5.0, the long-awaited new content editor "block editor", also known as Gutenberg, finally appeared in the core. It completely changed the post editing page and the principle of writing content. On some sites, such radical changes can break the current functionality, so it will be necessary to disable this editor there.

In this note, we will figure out how to revert to the old/classic/original WordPress editor. This can be done either by making hard changes in the code or by using plugins that allow customization of where to disable the new block editor.

How to completely disable the Gutenberg block editor (via code)

Disabling the editor is possible using the hook use_block_editor_for_post_type.

Insert the following code into the theme file functions.php or elsewhere:

GitHub
<?php
/***
 * Disables Gutenberg (the new block editor in WordPress).
 *
 * @version 2.0
 */

did_action( 'plugins_loaded' )
	? Kama_Disable_Gutenberg::init()
	: add_action( 'plugins_loaded', [ Kama_Disable_Gutenberg::class, 'init' ] );

final class Kama_Disable_Gutenberg {

	public static function init() {
		add_filter( 'use_block_editor_for_post_type', '__return_false', 100 );

		// disable <style id='global-styles-inline-css'>body{--wp--preset--color--black: #000000; ...
		// see wp_enqueue_global_styles()
		remove_action( 'wp_enqueue_scripts', 'wp_enqueue_global_styles' );
		remove_action( 'wp_footer', 'wp_enqueue_global_styles', 1 );

		remove_theme_support( 'core-block-patterns' ); // WP 5.5

		// disable basic css styles for blocks
		// IMPORTANT! when widgets on blocks or something else will be released, this line will need to be commented out.
		remove_action( 'wp_enqueue_scripts', 'wp_common_block_scripts_and_styles' );

		// don't do noneeded operations
		remove_filter( 'the_content', 'do_blocks', 9 );
		remove_filter( 'widget_block_content', 'do_blocks', 9 );

		add_action( 'admin_init', [ __CLASS__, 'on_admin_init' ] );

		self::remove_gutenberg_hooks();
	}

	public static function on_admin_init(){
		// Move the Privacy Policy help notice back under the title field.
		remove_action( 'admin_notices', [ WP_Privacy_Policy_Content::class, 'notice' ] );
		add_action( 'edit_form_after_title', [ WP_Privacy_Policy_Content::class, 'notice' ] );
	}

	/**
	 * Copy from Classic Editor plugin v1.6.3.
	 * @see https://plugins.svn.wordpress.org/classic-editor/trunk/classic-editor.php
	 */
	private static function remove_gutenberg_hooks( $remove = 'all' ) {
		remove_action( 'admin_menu', 'gutenberg_menu' );
		remove_action( 'admin_init', 'gutenberg_redirect_demo' );

		if ( $remove !== 'all' ) {
			return;
		}

		// Gutenberg 5.3+
		remove_action( 'wp_enqueue_scripts', 'gutenberg_register_scripts_and_styles' );
		remove_action( 'admin_enqueue_scripts', 'gutenberg_register_scripts_and_styles' );
		remove_action( 'admin_notices', 'gutenberg_wordpress_version_notice' );
		remove_action( 'rest_api_init', 'gutenberg_register_rest_widget_updater_routes' );
		remove_action( 'admin_print_styles', 'gutenberg_block_editor_admin_print_styles' );
		remove_action( 'admin_print_scripts', 'gutenberg_block_editor_admin_print_scripts' );
		remove_action( 'admin_print_footer_scripts', 'gutenberg_block_editor_admin_print_footer_scripts' );
		remove_action( 'admin_footer', 'gutenberg_block_editor_admin_footer' );
		remove_action( 'admin_enqueue_scripts', 'gutenberg_widgets_init' );
		remove_action( 'admin_notices', 'gutenberg_build_files_notice' );

		remove_filter( 'load_script_translation_file', 'gutenberg_override_translation_file' );
		remove_filter( 'block_editor_settings', 'gutenberg_extend_block_editor_styles' );
		remove_filter( 'default_content', 'gutenberg_default_demo_content' );
		remove_filter( 'default_title', 'gutenberg_default_demo_title' );
		remove_filter( 'block_editor_settings', 'gutenberg_legacy_widget_settings' );
		remove_filter( 'rest_request_after_callbacks', 'gutenberg_filter_oembed_result' );

		// Previously used, compat for older Gutenberg versions.
		remove_filter( 'wp_refresh_nonces', 'gutenberg_add_rest_nonce_to_heartbeat_response_headers' );
		remove_filter( 'get_edit_post_link', 'gutenberg_revisions_link_to_editor' );
		remove_filter( 'wp_prepare_revision_for_js', 'gutenberg_revisions_restore' );

		remove_action( 'rest_api_init', 'gutenberg_register_rest_routes' );
		remove_action( 'rest_api_init', 'gutenberg_add_taxonomy_visibility_field' );
		remove_filter( 'registered_post_type', 'gutenberg_register_post_prepare_functions' );

		remove_action( 'do_meta_boxes', 'gutenberg_meta_box_save' );
		remove_action( 'submitpost_box', 'gutenberg_intercept_meta_box_render' );
		remove_action( 'submitpage_box', 'gutenberg_intercept_meta_box_render' );
		remove_action( 'edit_page_form', 'gutenberg_intercept_meta_box_render' );
		remove_action( 'edit_form_advanced', 'gutenberg_intercept_meta_box_render' );
		remove_filter( 'redirect_post_location', 'gutenberg_meta_box_save_redirect' );
		remove_filter( 'filter_gutenberg_meta_boxes', 'gutenberg_filter_meta_boxes' );

		remove_filter( 'body_class', 'gutenberg_add_responsive_body_class' );
		remove_filter( 'admin_url', 'gutenberg_modify_add_new_button_url' ); // old
		remove_action( 'admin_enqueue_scripts', 'gutenberg_check_if_classic_needs_warning_about_blocks' );
		remove_filter( 'register_post_type_args', 'gutenberg_filter_post_type_labels' );

		// phpcs:disable Squiz.PHP.CommentedOutCode.Found
		// Keep
		// remove_filter( 'wp_kses_allowed_html', 'gutenberg_kses_allowedtags', 10, 2 ); // not needed in 5.0
		// remove_filter( 'bulk_actions-edit-wp_block', 'gutenberg_block_bulk_actions' );
		// remove_filter( 'wp_insert_post_data', 'gutenberg_remove_wpcom_markdown_support' );
		// remove_filter( 'the_content', 'do_blocks', 9 );
		// remove_action( 'init', 'gutenberg_register_post_types' );

		// Continue to manage wpautop for posts that were edited in Gutenberg.
		// remove_filter( 'wp_editor_settings', 'gutenberg_disable_editor_settings_wpautop' );
		// remove_filter( 'the_content', 'gutenberg_wpautop', 8 );
		// phpcs:enable Squiz.PHP.CommentedOutCode.Found

	}

}

To enable/disable Gutenberg for a specific post, you can use the hook use_block_editor_for_post.

Also, the Block editor can be disabled through the meta box by passing the parameter __block_editor_compatible_meta_box = false when registering the meta box, see more in the description of add_meta_box().

How to disable Gutenberg for custom post types (WordPress)

There are cases when a post type needs a simple interface without a block editor, then there is a need to disable the Gutenberg editor for a custom post type.

The example below shows how to disable Gutenberg for specified post types, while leaving it functional for all other post types.

This PHP snippet will disable the block editor for two post types: book, movie.

# Disables Gutenberg for custom post types
add_filter( 'use_block_editor_for_post_type', 'my_disable_gutenberg', 10, 2 );

function my_disable_gutenberg( $current_status, $post_type ) {

	$disabled_post_types = [ 'book', 'movie' ];

	return ! in_array( $post_type, $disabled_post_types, true );
}

The code can be used in the functions.php file or in a plugin.

See more about the hook: use_block_editor_for_post_type.

Disabling Gutenberg (via the Disable Gutenberg plugin)

Disable Gutenberg is an alternative to the Classic Editor plugin. Developed by a WP developer with 15 years of experience.

Disabling Gutenberg (via the Classic Editor plugin)

Classic Editor is a plugin that disables the Gutenberg block editor.

If you need to retain the ability to use Gutenberg on the site (have the ability to edit some articles in the new editor and others in the classic one), then completely disabling Gutenberg is not an option. In this case, WordPress developers recommend installing the "Classic Editor" plugin.

After installing and activating the plugin, you need to go to the settings page: Settings > Writing and choose which editor will be used by default, as well as allow/disallow the option for users to choose the editor.

If you leave the editor choice, then in the posts table, we will see the following links:

Briefly about the plugin capabilities:

  • Administrators can choose the default editor for all users.
  • Administrators can allow users to change their default editor.
  • When the editor is allowed, users can choose which editor to use for each post.
  • Each post opens in the last used editor, regardless of who last edited it (needed for compatibility when editing).

The plugin's operation principle is based on the hook use_block_editor_for_post_type.