Hi,
Meta Box has not supported a field to select the post format yet. But we can create a custom field radio
with options like WordPress post formats. Sample code below:
$meta_boxes[] = [
'title' => __( 'Post Meta', 'your-text-domain' ),
'id' => 'post-meta',
'fields' => [
[
'name' => __( 'Post Format', 'your-text-domain' ),
'id' => $prefix . 'post_format',
'type' => 'radio',
'options' => [
'gallery' => __( 'Gallery', 'your-text-domain' ),
'aside' => __( 'Aside', 'your-text-domain' ),
'status' => __( 'Status', 'your-text-domain' ),
'link' => __( 'Link', 'your-text-domain' ),
'image' => __( 'Image', 'your-text-domain' ),
'quote' => __( 'Quote', 'your-text-domain' ),
'video' => __( 'Video', 'your-text-domain' ),
'audio' => __( 'Audio', 'your-text-domain' ),
'chat' => __( 'Chat', 'your-text-domain' ),
],
'inline' => false,
],
],
];
Use the action hook rwmb_{$field_id}_after_save_field to set post format after saving the custom field.
add_action( 'rwmb_post_format_after_save_field', function( $null = true, $field, $new, $old, $object_id ) {
set_post_format( $object_id, $new );
}, 10, 5 );
Ok, then we can use the function get_post_format() to get the post format as default feature post format.