Is there a way to remove the default core/buttons block in Gutenberg, or other various blocks? We're creating our own buttons block and don't want the user to get it confused with the default one and would rather just remove it altogether.

I've tried the following but it tells me that $allowed_block_types is a bool and not an array.

function hide_default_button_block($allowed_block_types, $post) {
    // Remove the default Gutenberg button block
    if ($post->post_type === 'post' || $post->post_type === 'page') {
        $allowed_block_types = array_diff($allowed_block_types, ['core/button']);

    return $allowed_block_types;

add_filter('allowed_block_types', 'hide_default_button_block', 10, 2);

I'm trying to do this in just a theme currently, but will need to implement this in a plugin eventually that will replace core blocks with our revised ones.

1 Answer 1


This added to the functions.php allows the removal of specific Gutenberg blocks.

function hide_default_blocks($allowed_block) {
    $blocks = WP_Block_Type_Registry::get_instance()->get_all_registered();


    return array_keys($blocks);

add_filter('allowed_block_types_all', 'hide_default_blocks');

Part of the issue is that it is core/buttons and not core/button but also the method of removal was incorrect.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.