Back in the early days of Gutenberg (around 2018–2019), many developers were caught off guard by how it interacted with Custom Post Types (CPTs). A common issue? You’d register a CPT, but it would stubbornly load the Classic Editor instead of the sleek new block editor.
Fast-forward to 2025: Gutenberg is now the default and powerful editing experience in WordPress. So if you’re still seeing the classic editor when editing a CPT, it’s time to bring your code up to speed.
Let’s go over how to properly enable the Gutenberg (block) editor on a custom post type today.
🛑 The Problem (Classic Editor Appears Instead of Gutenberg)
Here’s a sample of an older CPT registration function that still results in the Classic Editor:
function create_posttype() {
register_post_type( 'companies',
array(
'labels' => array(
'name' => __( 'شرکتهای عضو' ),
'singular_name' => __( 'شرکت' )
),
'supports' => array('title', 'editor', 'custom-fields', 'excerpt', 'thumbnail'),
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'companies'),
)
);
}
add_action( 'init', 'create_posttype' );
Looks fine, right? The 'editor'
support is there. But still — no Gutenberg. Why?
✅ The Solution: Add show_in_rest => true
To make Gutenberg work, two conditions must be met:
'editor'
must be included in thesupports
array (you already have this ✅).- Most importantly:
'show_in_rest' => true
must be present. This makes the post type accessible via the REST API — a requirement for Gutenberg.
✅ Updated and Correct Code:
function create_posttype() {
register_post_type( 'companies',
array(
'labels' => array(
'name' => __( 'شرکتهای عضو' ),
'singular_name' => __( 'شرکت' )
),
'supports' => array('title', 'editor', 'custom-fields', 'excerpt', 'thumbnail'),
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'companies'),
'show_in_rest' => true, // 👈 This line enables Gutenberg
)
);
}
add_action( 'init', 'create_posttype' );
And that’s it. No need for complex filters or hacky workarounds.
🧠 Why show_in_rest
Matters
The block editor (Gutenberg) is a React-based application that relies heavily on the WordPress REST API to function. If your custom post type doesn’t support show_in_rest
, the editor can’t fetch or manage its data in the expected way — so WordPress falls back to the Classic Editor.
🚀 Bonus: Customizing Further
Once Gutenberg is enabled, you can:
- Add custom blocks with
block.json
- Use block templates for structure
- Create block variations specific to your CPT
You’ve now opened the door to a fully modern editing experience!
✅ Final Checklist for Gutenberg-Ready CPTs
Make sure your register_post_type()
call includes:
'supports' => array('editor', ...)
'show_in_rest' => true
And you’re good to go! 💪
🧩 Useful Resources
Have questions or want to take your CPTs to the next level with block patterns or full site editing? Drop a comment below or reach out — let’s build the future of WordPress together. 🌐