Hi,
I have used CMB2 to add meta boxes to my post types in my own theme, and I only get the value from the meta boxes in the search and filter form. How do I get the labels? Is the only alternative to add the options manually? I have only found (private) answers to how this works when using ACF.
Here is an example of how a select meta box is added:
$product->add_field( array(
'id' => 'id_here',
'name' => esc_html__( 'Example', 'text-domain' ),
'type' => 'select',
'default' => '0',
'options_cb' => 'example_options'
) );
function example_options() {
return array(
'0' => esc_html__( 'None', 'text-domain' ),
'1' => esc_html__( 'One', 'text-domain' ),
'2' => esc_html__( 'Two', 'text-domain' ),
);
}
Kind regards,
Lisa Kriga