Created
May 31, 2021 14:52
-
-
Save robertannett/8fe04e17d284791692cb5e03420f3f29 to your computer and use it in GitHub Desktop.
Wordpress - Disable Gutenberg blocks / Whitelist Blocks
This file contains hidden or 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
/* | |
** Reference: https://rudrastyh.com/gutenberg/remove-default-blocks.html | |
*/ | |
add_filter( 'allowed_block_types', 'custom_allowed_block_types', 10, 2 ); | |
function custom_allowed_block_types( $allowed_blocks, $post ) { | |
$allowed_blocks = array( | |
'core/paragraph', | |
'core/image', | |
'core/heading', | |
'acf/custom-block-one', | |
'acf/custom-block-two', | |
'acf/custom-block-three' | |
); | |
if( $post->post_type === 'page' ) { | |
$allowed_blocks[] = 'core/shortcode'; | |
} | |
return $allowed_blocks; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment