Excluding a post type from using the block editor

A simple code snippet to exclude a post type from the using the block editor.

<?php
/**
 * Excludes the person post type from using the block editor.
 *
 * @param bool   $output    True or false whether the block editor should be used.
 * @param string $post_type The current post type.
 *
 * @return bool             True or false whether the block editor should be used.
 */
function hd_remove_block_editor_from_post_type( $output, $post_type ) {

	// if the post type is the person post type.
	// replace 'hd_person' with the name of your post type.
	if ( 'hd_person' === $post_type ) {
		$output = false;
	}

	// return the output - whether to use the block editor or not.
	return $output;

}

add_filter( 'use_block_editor_for_post_type', 'hd_remove_block_editor_from_post_type', 10, 2 );

Posted

in

by

Tags: