Subscribe On YouTube

Join other subscribers and enjoy other Divi video tutorials!

How To Enable The Classic Or Block Editor Per Post Type In Divi

Nelson Miller Profile Orange
In this tutorial I will show you how to enable the WordPress Classic or Gutenberg Block editor per post type in Divi.

▶️ Please watch the video above to get all the exciting details! 👆

Divi Default – All Or Nothing

The Divi theme provides a handy setting in Divi>Theme Options>Builder>Advanced>Enable Classic Editor
 to enable the Classic editor instead of the Block (aka Gutenberg) editor.

enable the classic editor in the Divi Theme options

However, this is only one single setting that applies across the site for ALL post types. While this may not sound important, veterans of website creation will know this is not ideal, because some post types require the block editor, and some require the classic editor. So how can we solve this?

Why would you want the Classic editor? If you want to use the Divi Builder in the backend, you need the Classic editor. Or if you are using a plugin like The Events Calendar with Divi, you need the Classic editor. Or if you simply prefer a large, simple editor like a normal document editor, then you need the Classic editor. In these situations, you most likely want a different editor for different post types.

Enable The Classic Or Blog Editor Per Post Type With PHP Code

The first method I will show you to enable either the Classic or the Block editor per post type in WordPress is by using custom PHP code. For those who are unfamiliar with it, PHP code is like a set of instructions that web developers use to make websites do cool things. It works behind the scenes to handle some of the core features of WordPress, and is the type of code we need to use to modify which WordPress editor is used for each post types.

This code snippet below is a PHP function used to disable the Gutenberg Block editor for specific post types in WordPress and enable the Classic editor instead. 

Where To Paste The PHP Code

1. Divi Assistant
If you are using our Divi Assistant plugin, simply paste the code in the PHP tab in the custom code window in the Divi Visual Builder.

2. Child Theme
If you are using a child theme, paste this code into the functions.php file. If you don't have a child theme, you can generate a child theme directly on your site or download our free child theme.

3. Code Snippet Plugins
Otherwise, install a dedicated code snippet plugin, create a new snippet, and paste this code into the PHP code editor.

If you need help understanding where to paste the code, please check out our complete guide about where to add custom PHP code snippets in Divi.

/**
 * Disabling Gutenberg
 *
 * @param $use_block_editor
 * @param $post_type
 *
 * @return false|mixed
 */
if (!function_exists('pac_ft_disable_gutenberg')):
    function pac_ft_disable_gutenberg($use_block_editor, $post_type)
    {
        $post_types = ['post', 'page', 'project'];
        if (in_array($post_type, $post_types)) {
            $use_block_editor = false;
        }

        return $use_block_editor;
    }

    add_filter('use_block_editor_for_post_type', 'pac_ft_disable_gutenberg', 999, 2);
endif;

This snippet of PHP code is like a switch that turns off the Gutenberg Block editor for selected post types on your WordPress website. In the code, the post types Posts, Pages, and Projects are added, which means these will use the Classic editor. Basically the code is saying, “Hey, don’t use Gutenberg here, use the Classic editor instead for these specific post types.”

How To Add Or Remove Selected Post Types

As mentioned, there are three default post types in this code snippet. But this is meant to be edited based on your preference. For example, if you want to use the Gutenberg Block editor for Posts, you can simply remove the ‘post’, from the $post_types = line. Or if you have another post type, for example called “Cats” and the slug is cats, then you would add ‘cats’ to the $post_types = line within the brackets.

Warning: Keep in mind that you must be extremely careful when editing PHP code on a live website. One wrong move can easily crash the site. If you want to do this with a simple plugin setting instead, see the method described below.

how to Enable Classic Editor Per Post Type using the Divi Assistant plugin

Subscribe For More Things Like This!

At the start of each month, we send out a recap newsletter from the month before with family news, Divi news, our latest tutorials, and product news. Occasionally, if the news is too exciting to wait, we will send out another email separate from the monthly newsletter. That’s what you get when you subscribe, and of course you can unsubscribe if you are no longer interested!

Blog Post Optin
Divi Logo (2)

Shop Our Divi Products

Plugins • Courses • Templates

Visit The Shop

Featured Products

Asset 4

New! Trail Guides

Follow a series of blog posts carefully arranged around a specific topic or goal! Keep track of your progress by marking posts completed, just like a free course!

View Trial Guides

Divi Tutorials On YouTube

Our videos have views! Join subscribers and enjoy over video tutorials!

Visit Our Channel

Leave A Response!

By commenting you agree to our Blog & YouTube Comments Policy

2 Comments

Comments By Others

  1. shelley Giese

    Hello this is a great blog post. But what if you need to do the opposite. What if all of your site runs with divi and classic editor except for one post type which needs to use guttenberg blocks to run. Right now to deal with that, if I have to make a change to that post type I have to turn off the classic editor setting and grit my teeth while dealing with blocks and then remember to switch the classic editor back on again when I am done. Is there a way to leave the classic editor on but somehow target a particular post type with php so that post type uses blocks instead? I use your divi calendar by the way and love it.

    Reply
    • Hemant Gaba <span class="comment-author-role-label"><a href="https://www.peeayecreative.com/product/divi-adventure-club/" class="comment-author-role-link" rel="external nofollow" target="_blank">Divi Adventure Club Member</a></span>

      Hi Shelley!

      You can try adding the following code in function.php of the child theme:

      function enable_gutenberg_for_custom_post_type($can_edit, $post_type) {
      // Replace ‘your_post_type’ with the desired post type.
      if ($post_type === ‘your_post_type’) {
      $can_edit = true; // Enable Gutenberg editor.
      }

      return $can_edit;
      }
      add_filter(‘use_block_editor_for_post_type’, ‘enable_gutenberg_for_custom_post_type’, 10, 2);

      Replace ‘your_post_type’ in the code with the slug of the post type for which you want to enable Gutenberg.

      Also, please make these changes in the staging site first. Hope it helps!

      Reply

Submit a Comment

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

Recent Posts

0

Your Cart