Home › Forums › Gutenberg › acf Blocks and "allowed_block_types" › Reply To: acf Blocks and "allowed_block_types"
This is what I’m using to disable core blocks, and WooCommerce blocks. The core blocks I want to use are at the bottom.
function remove_default_blocks($allowed_blocks){
// Get widget blocks and registered by plugins blocks
$registered_blocks = WP_Block_Type_Registry::get_instance()->get_all_registered();
// Disable Widgets Blocks
unset($registered_blocks['core/calendar']);
unset($registered_blocks['core/legacy-widget']);
unset($registered_blocks['core/rss']);
unset($registered_blocks['core/search']);
unset($registered_blocks['core/tag-cloud']);
unset($registered_blocks['core/latest-comments']);
unset($registered_blocks['core/archives']);
unset($registered_blocks['core/categories']);
unset($registered_blocks['core/latest-posts']);
unset($registered_blocks['core/shortcode']);
// Disable WooCommerce Blocks
unset($registered_blocks['woocommerce/handpicked-products']);
unset($registered_blocks['woocommerce/product-best-sellers']);
unset($registered_blocks['woocommerce/product-category']);
unset($registered_blocks['woocommerce/product-new']);
unset($registered_blocks['woocommerce/product-on-sale']);
unset($registered_blocks['woocommerce/product-top-rated']);
unset($registered_blocks['woocommerce/products-by-attribute']);
unset($registered_blocks['woocommerce/featured-product']);
// Now $registered_blocks contains only blocks registered by plugins, but we need keys only
$registered_blocks = array_keys($registered_blocks);
// Merge allowed core blocks with plugins blocks
return array_merge(array(
'core/image',
'core/paragraph',
'core/heading',
'core/list'
), $registered_blocks);
}
add_filter('allowed_block_types', 'remove_default_blocks');
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.