WordPress added Gutenberg / block editor in its 5th version and it's enabled by default for Post and Page post types.
It might be enabled by default for all custom post types in close future so as a WordPress developer I want to know how to disable this editor for my own custom post types? I want to keep classic editor for the post types that I registered from my plugins or themes.
The easiest way to disable Gutenberg is to install my free plugin, Disable Gutenberg. It is a simple plugin focused on one thing: disabling Gutenberg and restoring the default classic WP Editor screen. Just enable the plugin, choose your options and done.
add support for the editor. add the show_in_rest key and set it to true via your custom post type. As you can see, the above code snippet just set the 'show_in_rest' parameter to 'TRUE'. After this step, when you create or edit a custom post type, you will see the Gutenberg editor visible and enabled.
Once you have installed the Classic editor you need to disable Gutenberg editor on the setting page. Go to Settings > Writing and checkmark on either of the options under Classic editor setting menu. Finally save all changes and you are done.
Simply go to the Settings » Writing page in your WordPress admin area. You will see the option to do this under “Classic editor settings”. Don't forget to click on the save changes button to store your settings. You will now be able to see a new link under the Posts menu to create new posts using the classic editor.
It's possible to simply disable the editor using a WordPress filter.
If you want to disable the block editor only for your own post types, you can add following code into your plugin or functions.php
file of your theme.
add_filter('use_block_editor_for_post_type', 'prefix_disable_gutenberg', 10, 2);
function prefix_disable_gutenberg($current_status, $post_type)
{
// Use your post type key instead of 'product'
if ($post_type === 'product') return false;
return $current_status;
}
If you want to disable the block editor completely (Not recommended), you can use following code.
add_filter('use_block_editor_for_post_type', '__return_false');
If you want to disable the Gutenberg editor only for your own post types, you can add following code into your plugin or functions.php
file of your theme.
add_filter('gutenberg_can_edit_post_type', 'prefix_disable_gutenberg', 10, 2);
function prefix_disable_gutenberg($current_status, $post_type)
{
// Use your post type key instead of 'product'
if ($post_type === 'product') return false;
return $current_status;
}
If you want to disable the Gutenberg editor completely (Not recommended), you can use following code.
add_filter('gutenberg_can_edit_post_type', '__return_false');
as the other users shown above it is possible yes. Also, i'd like to make the following known.
In the latest Wordpress or Wordpress 5+ - (With Gutenberg) The 2 methods have the same effect to removing Gutenberg but also have different options when doing so:
(Insert both to functions.php or custom plugin functions)
To remove Gutenberg from your post type:
add_filter('use_block_editor_for_post_type', 'prefix_disable_gutenberg', 10, 2);
function prefix_disable_gutenberg($gutenberg_filter, $post_type)
{
if ($post_type === 'your_post_type') return false;
return $gutenberg_filter;
}
The above will remove Gutenberg editor completely from your custom post type but also leave other meta boxes/etc available and untouched.
However, if you wish to remove the text editor/text area itself - or other default options WordPress also considers this as Gutenberg, so you can remove this specifically and remove Gutenberg at the same time by adding the following:
add_action('init', 'init_remove_editor',100);
function init_remove_editor(){
$post_type = 'your_post_type';
remove_post_type_support( $post_type, 'editor');
}
The above will disable Gutenberg & the 'editor' of wordpress. This can replaced with other metabox/data options. (Author / Thumbnail /Revisions etc)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With