Home › Forums › Bug Reports › acf_register_block and filter block_categories issue with 5.8.0 › Reply To: acf_register_block and filter block_categories issue with 5.8.0
I’ve seen this option, thank you. But this way, I can’t remove the default block in pages.
I’ve found this post which can be the solution:
https://rudrastyh.com/gutenberg/remove-default-blocks.html
But I have to list manually all of the block I want to use for each post type: can not exclude a whole category…
add_filter( 'allowed_block_types', 'mlp_welcoop_allowed_block_types', 10, 2 );
function mlp_welcoop_allowed_block_types( $allowed_blocks, $post ) {
if( $post->post_type === 'post' ) {
$allowed_blocks = array(
'core/shortcode'
);
} else {
$allowed_blocks = array(
'acf/header-default',
'acf/header-light'
);
}
return $allowed_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.