Support

Account

Home Forums General Issues Hiding/removing ACF custom (taxonomy) meta boxes in Gutenberg editor sidebar Reply To: Hiding/removing ACF custom (taxonomy) meta boxes in Gutenberg editor sidebar

  • @fzs, thanks for your bug fix inspiration!

    Somehow in WP 6.4.2 it didn’t work for me.

    When I removed $taxonomy->meta_box_cb === false it worked, but for all categories on all post types.

    But since I only want to hide a specific custom category, I simply replaced it with $taxonomy->name === 'event-category'.

    So the final modified version is this:

    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->name === 'event-category' ){
            $data_response = $response->get_data();
            $data_response['visibility']['show_ui'] = false;
            $response->set_data( $data_response );
        }
        return $response;
    }, 10, 3 );