@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 );
John, do you know if there is an official fix on the way?
It’s been a few months, but I ended up here because the “Advanced Settings => Visibility => Meta Box => No Meta Box” still doesn’t seem to work in the block editor?
Would appreciate an update from the official team!