← Back to notes
snippet 1 min read PHP 7.4+ WP 5.8+

Disable the Gutenberg Editor for Specific Custom Post Types or User Roles

Disable the WordPress block editor selectively for a custom post type or selected user roles while leaving Gutenberg enabled everywhere else.

Updated Sep 7, 2026 #wordpress #gutenberg #admin #php #snippet

WordPress lets you replace the block editor selectively instead of turning Gutenberg off across the entire site. This is useful when a legacy custom post type has a custom metabox workflow, or when a content team should use the classic editor for a specific role.

Add the snippet to a child theme’s functions.php file or use a code snippets plugin. The filters below can be used independently or together.

Disable Gutenberg for a custom post type

Replace legacy_case with the post type slug that should use the classic editor.

functions.php
add_filter( 'use_block_editor_for_post_type', function( $use_block_editor, $post_type ) {
if ( 'legacy_case' === $post_type ) {
return false;
}
return $use_block_editor;
}, 10, 2 );

The filter runs before the editor loads and receives the post type slug. It does not alter the editor for posts, pages, or other custom post types.

Disable Gutenberg for a user role

This example disables the block editor for users with the author role while preserving it for editors and administrators.

functions.php
add_filter( 'use_block_editor_for_post', function( $use_block_editor, $post ) {
if ( ! $post instanceof WP_Post ) {
return $use_block_editor;
}
$user = wp_get_current_user();
if ( in_array( 'author', (array) $user->roles, true ) ) {
return false;
}
return $use_block_editor;
}, 10, 2 );

For a combined rule, check both $post->post_type and the current user’s roles in the same callback. Prefer a role or capability check over a username so the behavior continues to work when staff accounts change.

Important compatibility notes

Disabling Gutenberg does not remove the post type’s metaboxes, templates, or REST API support. It only changes the editing interface. Test custom fields, autosave, revisions, and editorial plugins after applying the rule.

The official use_block_editor_for_post_type and use_block_editor_for_post references document the two filters. For related admin-only customization, see how to add custom columns and filterable dropdowns to post lists.