Disable the WordPress Block Editor for specific post types using code

by Dan
Last updated: September 26th, 2020

I feel like I’m in the minority here, but I’m actually a big fan of the new WordPress (formally Gutenberg) Block Editor! I do concede though that there are a number of cases where it’s perhaps not the most appropriate.

Most of our clients want highly customisable sites that are easy for them to create and craft web pages as they see fit – for this I turn to building a module based system utilising the incredible Advanced Custom Fields (ACF) plugin and their Flexible Content field type.

When I do this, it often renders the standard Block Editor useless, since there’s nowhere in the page template to render that content (as it’s now module driven).

This is when it might be appropriate to disable the Block Editor, and more often than not, remove the editor entirely.

Use the following function inside of your functions.php file, updating the $post_type array to include each of the post types you’d like to disable the editor on.

add_filter('use_block_editor_for_post_type', 'speccy_disable_block_editor', 10, 2); function speccy_disable_block_editor($use_block_editor, $post_type) { if (in_array($post_type, array('page', 'posts', 'resources'))) { return false; } return $use_block_editor; }

we think you'll probably like these too