Switch a plugin's custom post type that opens in the classic editor over to the block editor.
add_filter( 'register_post_type_args', function ( array $args, string $post_type ): array {
if ( 'portfolio' === $post_type ) {
$args['show_in_rest'] = true;
// The block editor also needs the editor feature.
$args['supports'] = array_unique( array_merge( (array) ( $args['supports'] ?? [ 'title' ] ), [ 'editor' ] ) );
}
return $args;
}, 10, 2 );
Always add PHP to a staging site first, or have FTP or file manager access ready, so you can undo it if something goes wrong.
The block editor only works for post types that are available in the REST API. If a plugin or theme registers a post type without that, it opens in the classic editor. This snippet turns the REST API on for it.
The register_post_type_args filter changes a post type’s settings as it’s registered. Setting show_in_rest to true makes it available to the REST API, and adding editor to its supports gives it a content area. WordPress then opens it in the block editor.
/wp-json/wp/v2/, like posts.'portfolio' to the post type’s name.Edit an entry of that post type. It should open in the block editor.