Meta Box
Support › General › Remove metabox field with filter
I'm trying to create a filter so we can remove fields from a metabox.
This is the function that I have created to it. It returns null as aspected, but the field is still there in the metabox.
Code:
/** * filter fields */ public function syb_filter_fields( $fields ) { foreach ( $fields as $field ) { if ( $field['id'] == 'boat-details' ) { foreach ($field['fields'] as $key => $value) { if ( $value["id"] == 'field-id' ) { $value = NULL; } } } } return $fields; }
Hi Joseph,
You can try unset( $field['fields'][$key] ) instead of setting the $value = null. How did you run the function?
unset( $field['fields'][$key] )
$value = null