• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

I Like Kill Nerds

The blog of Australian Front End / Aurelia Javascript Developer & brewing aficionado Dwayne Charrington // Aurelia.io Core Team member.

  • Home
  • Aurelia 2
  • Aurelia 1
  • About
  • Aurelia 2 Consulting/Freelance Work

How to Hide Meta Boxes in WordPress Gutenberg

Wordpress · October 31, 2022

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.

Dwayne

Leave a Reply Cancel reply

0 Comments
Inline Feedbacks
View all comments

Primary Sidebar

Popular

  • Testing Event Listeners In Jest (Without Using A Library)
  • How To Get The Hash of A File In Node.js
  • Thoughts on the Flipper Zero
  • Waiting for an Element to Exist With JavaScript
  • How To Paginate An Array In Javascript
  • How To Mock uuid In Jest
  • How To Get Last 4 Digits of A Credit Card Number in Javascript
  • How to Use Neural DSP Archetype Plugins With the Quad Cortex
  • How To Decompile And Compile Android APK's On A Mac Using Apktool
  • NBN Box Installed Inside of Garage, Where Do You Put The Modem?

Recent Comments

  • Kevmeister68 on Start-Ups and Companies That Embrace Work From Anywhere Will Be More Likely to Survive the Coming Recession in 2023
  • kevmeister68 on What Would Get People Back Into the Office?
  • Dwayne on PHP Will Not Die
  • Dwayne on How to Create a Blockchain With TypeScript
  • kevmeister68 on PHP Will Not Die

Copyright © 2023 · Dwayne Charrington · Log in

wpDiscuz