Choose Your Editor On Each Post Type
Divi provides a setting in Divi>Theme Options>Builder to enable the Classic editor instead of the Gutenberg/Block editor. However, this setting applies across the site for all post types, which is not ideal, because some post types require the block editor, and some require the classic editor. If you want some post types to use the Block Editor, and some to use the Classic Editor (so that you can use the Divi Builder on the backend), then you have come to the right place! In this tutorial, I will show yo how to enable the WordPress Classic or 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.
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 Divi Assistant
Here are the simple steps to enable the Classic Editor per post type using our popular Divi Assistant plugin:
- Install and activate the Divi Assistant plugin
- Click on the Utility Helper tab and the Editor subtab
- Enable the setting
I hope that is easy enough for you! 😉
These simple settings allow you to choose which editor to use for each post type on your site. Enabling the setting for the associated post type will enable the Classic editor for that post type.
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.
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!