ThemeIM Blog Details

How to Disable Gutenberg Without Plugins ( A Complete Note)

Disable Gutenberg Without Plugins

 

Disabling Gutenberg might be easy by using the ‘Classic Editor’ plugin. But we are sure many of you are struggling to disable Gutenberg without plugins.

Although WordPress 5.0 is now available, not everyone is a big fan of the Gutenberg block editor. Instead of using a plugin, it’s easier to disable Gutenberg with simple code. This is a burning question as Gutenberg has over 5 million active installations.

And many of them are looking for a convenient solution to disable the Gutenberg editor without using any plugin.
In this article, we will instruct you to disable the Gutenberg block editor with a simple line of code.

Before that, many of you might be wondering – “why do I need to disable Gutenberg?” So, let’s break it down for you – 

Related One: How to Enable Automatic Plugin Updates

Why do you need to disable Gutenberg?

Many users are saying – “ the new WordPress sucks”
But, why? 

— That’s because – along with the new WordPress 5.0, Gutenberg has received a lot of criticism. People want the WordPress 5 classic editor. Let’s look at the problems for which you may need to turn off Gutenberg –

  • The TinyMCE Advanced plugin won’t let you use the powerful features of the editor toolbar.
  • Heavy JavaScript is used that will slow down the typing speed.
  • In terms of using short-code buttons, the editor toolbar can’t integrate with other plugins.
  • The new WordPress 5.0.1 has a rivalry with the Yoast SEO (version 9.2.1) plugin.
  • Plugins like WPML, ACF are not fully compatible either.
  • Inserting images and editing articles has become harder than the previous editor.

As you can see, Gutenberg is still not stable enough to work with third-party plugins. Otherwise, you will have conflict issues. As a result, Gutenberg should be disabled and you may want to use the WordPress classic editor.

How to disable Gutenberg without plugins (Using simple code)?

It is very easy to disable Gutenberg with a single line of code. All you need to do is – copy and paste the following code inside your functions.php file under your theme editor – 

add_filter( 'use_block_editor_for_post', '__return_false' );

This code will command WordPress whether to use the Gutenberg editor or not by hooking into the use_block_editor_for_post filter. Therefore, Gutenberg will remain disabled while you are writing articles.

If you want, Gutenberg can be also disabled for a specific post type. For this, you will need to add the following code inside the functions.php file –   
add_filter( 'use_block_editor_for_post','my_enable_gutenberg_specific_post', 10, 2 );

function my_enable_gutenberg_specific_post( $enabled, $post ) {
return ($post->post_type === ‘page’ && $post->ID===2)? $enabled: false;
}

Just like the previous code, this works in a similar way and will hook into the use_block_editor_for_post filter. The my_disable_gutenberg_specific_post is a callback function that returns false when the specific post and post type are equal. A total of 10 callback functions will be run and 2 arguments will be accepted by the callback function. 

So, is it simple or not? And you don’t have to install an extra plugin for this.

How to enable Gutenberg for a specific page?

You may need to apply Gutenberg for a specific page id. Just as we have shown how to disable Gutenberg, you can enable it with simple code. 

For enabling Gutenberg for a specific type of post, you will need to add the following code in the functions.php file – 

add_filter( 'use_block_editor_for_post','my_enable_gutenberg_specific_post', 10, 2 );
function my_enable_gutenberg_specific_post( $enabled, $post ) {
return ($post->post_type === 'page' && $post->ID===2)? $enabled: false;
}

This code works similarly to the codes we showed above to disable Gutenberg. By hooking into the use_block_editor_for_post filter, this code will decide whether to use Gutenberg or not while writing articles.   

Here, the my_enable_gutenberg_specific_post is a callback function that returns true when the specific post and post type are equal.

Colclusion:

After reading this article, you may find out the reasons to disable the Gutenberg editor from your WordPress site. And now you know the process of disabling it without using any plugin. You may want to keep Gutenberg fully disabled for old websites. But we suggest enabling it for a specific post type. As you might need it for the new websites. 

— Hope that helps! See you at our next insightful blog.  

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.