How to Hide Meta Boxes in WordPress Gutenberg

When WordPress introduced the Gutenberg editor, it was a mess, to say the least. Everything was turned upside for developers and things that worked in previous versions were completely broken when Gutenberg was released.

One of the things that were broken in WordPress was the ability to hide a meta box on the editor screen. Instead of setting meta_box_cb to false and expecting the box the hidden, nothing happens.

Well, there is a way you can hide meta boxes by using the following snippet of code inside of functions.php

add\_filter('rest\_prepare\_taxonomy', function ($response, $taxonomy, $request) {
    $context = !empty($request['context']) ? $request['context'] : 'view';

    // Context is edit in the editor
    if ($context === 'edit' && $taxonomy->meta\_box\_cb === false) {

        $data\_response = $response->get\_data();

        $data\_response['visibility']['show\_ui'] = false;

        $response->set\_data($data\_response);
    }

    return $response;
}, 10, 3);

By leveraging the rest_prepare_taxonomy filter, we can modify the visibility of a meta box.

On your register_taxonomy call you can supply "meta_box_cb" => false, and using the above code, the box will be hidden.