Created
June 9, 2022 23:32
-
-
Save khromov/9451c9d5d0d7260fed3ea37535d1ef2b to your computer and use it in GitHub Desktop.
WordPress Gutenberg - Control allowed blocks by post type
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'allowed_block_types_all', function($allowed_block_types, $block_editor_context) { | |
if ( $block_editor_context->post->post_type === 'post' ) { | |
return [ | |
'acf/my-cool-block', | |
'core/paragraph' | |
]; | |
} | |
return $allowed_block_types; | |
}, 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment