Gutenberg Block Editor allowed block types
<?php
/**
* allowed blocks type
* Block List: https://en.support.wordpress.com/wordpress-editor/blocks/
*
* @param bool|array $allowed_block_types Array of block type slugs, or
* @param object The post resource data.
*/
function filter_allowed_block_types( $allowed_block_types, $post ) {
// echo '<pre>';
// var_dump($allowed_block_types);
// echo '</pre>';
switch ($post->post_type) {
case 'custom_post':
$allowed_block_types = [
'core/paragraph',
];
break;
default:
$allowed_block_types = [
'core/paragraph',
'core/heading',
'core/image',
'core-embed/youtube'
];
}
return $allowed_block_types;
}
add_filter( 'allowed_block_types', 'filter_allowed_block_types', 10, 2 );