Fortunately, there are numerous ways to disable Gutenberg programmatically. Let’s look at each of them.

Disable Gutenberg Completely

As expected, Gutenberg is changing constantly. As of now, you can use either of the following filter hooks to disable Gutenberg completely on your entire site:

// disable for posts
add_filter('use_block_editor_for_post', '__return_false', 10);

// disable for post types
add_filter('use_block_editor_for_post_type', '__return_false', 10);

Either of these hooks will suffice; no need to add both (although technically it won’t hurt anything). The idea is that the different hooks enable you to identify both single posts and archive views. These hooks work for Gutenberg plugin version 4.1 or later, and WordPress 5.0 (beta) and later. For older versions, use the code below.

Conditional technique

In case it is useful for anyone, here is an example of how to conditionally disable Gutenberg/Block Editor depending on which version of WordPress is running.

// Disable Gutenberg

if (version_compare($GLOBALS['wp_version'], '5.0-beta', '>')) {
	
	// WP > 5 beta
	add_filter('use_block_editor_for_post_type', '__return_false', 10);
	
} else {
	
	// WP < 5 beta
	add_filter('gutenberg_can_edit_post_type', '__return_false', 10);
	
}