Ask any question about WordPress here... and get an instant response.
Post this Question & Answer:
How do I use a custom post type with the block editor in WordPress?
Asked on Jan 01, 2026
Answer
To use a custom post type with the block editor in WordPress, you need to ensure that the custom post type is registered with support for the block editor (Gutenberg). This involves setting the 'show_in_rest' parameter to true when registering the custom post type.
<!-- BEGIN COPY / PASTE -->
function my_custom_post_type() {
$args = array(
'label' => 'Books',
'public' => true,
'show_in_rest' => true, // Enables the block editor
'supports' => array('title', 'editor', 'thumbnail'),
'has_archive' => true,
'rewrite' => array('slug' => 'books'),
);
register_post_type('book', $args);
}
add_action('init', 'my_custom_post_type');
<!-- END COPY / PASTE -->Additional Comment:
- Ensure that the 'show_in_rest' parameter is set to true to enable the block editor for the custom post type.
- Include 'supports' to specify which features the custom post type should support, such as 'title', 'editor', and 'thumbnail'.
- Register the custom post type using the 'init' action hook to ensure it is available when WordPress initializes.
Recommended Links:
