How to disable Gutenberg in WordPress 5.0

0
How to disable Gutenberg in WordPress 5.0

Quick Way:

With the arrival of WordPress 5.0 Gutenberg has been included by default in all the installations, this forces to “change the chip” and adapt to the new block editor.

If you are one of those who prefer to go back to the classic WordPress editor and do not know how to disable Gutenberg in WordPress, you can do it by installing the “Classic Editor” plugin from this link in the official WordPress repository.

Just activate it you can go to Settings> Writing and you will have the option to completely disable the editor by blocks or leave it to decide in the list of posts whether to write using the classic editor or the new Gutenberg.

Other ways:

Version 5.0 of WordPress is just around the corner, scheduled for the end of August. As you already know at this point of the film, it will come with the new Gutenberg editor integrated into its core.

We have been knowing that this day will be over a year, and during all this time there has been a lot of talk about Gutenberg : if it’s good, if it’s bad, that if the lock-in, if I’m going to lose everything I already had, what will happen to my Divi / Elementor / whatever, etc …

What is likely is that many people at the beginning want to remove or deactivate, until you can prove well, spend some time, evolve, mature and take your first steps, etc … and until you or your client is ready for it .

Although there are many plugins for this, we will see how we can disable it  with just a few lines of code.

Deactivates Gutenberg completely

Although it may seem incredible, you will only need a line of code to completely disable Gutenberg , and go back to the classic WordPress editor. Simply add the following to your functions.php or utility plugin:

We simply return false to the gutenberg_can_edit_post_type filter . __return_false  is a WordPress function , which simply does precisely what it says, return a false .

Disable Gutenberg for a specific post type

And what if I want to deactivate Gutenberg only for certain post types? Or put another way, what if I just want Gutenberg for a certain type of post type?

By default we will have it available for the entries and the pages. And also for all those Custom Post Types who meet the following requirements in their registry:

  • supports => array (‘editor’);
  • show_in_rest => true

That is, they must support the editor, and be accessible from the REST API. If we do not control the CPTs in our site because they have been declared in a plugin and / or topic which does notwe must we want to play, we can disable Gutenberg as follows:

An example similar to the previous one, although we will only return false if the condition that $ post_type is equal to the one we want to deactivate Gutenberg is met , in this example ‘product’.

If we wanted to deactivate it for example in the pages, we can add one more condition in the same function:

Disable Gutenberg for a specific role

Another need that we can have is to deactivate the new editor for a specific role. In this way your editors, collaborators, authors, etc … will continue to see the classic editor.

In this example, we deactivate Gutenberg for all the roles below administrator:

Conclusions

Playing a little with the roles and the types of content, we can disable Gutenberg at our whim with a few lines of code, without the need to install additional plugins.

LEAVE A REPLY