Skip to main content

Add fields to the booking item

BA Book Everything plugin uses CMB2 plugin to create metaboxes with custom fields. So you can follow CMB2 documentation to easily create own metaboxes and custom fields. You can also use one of the plugin hooks to add new custom field to an existing metabox, as shown below. Then you can use standard function get_post_meta($post_id, 'new_field_slug', true) to show new field in your booking object post template.

Adding custom fields to the booking item
add_action('cmb2_booking_obj_after_av_dates', 'customtheme_cmb2_booking_obj_after_av_dates', 10, 1);
function customtheme_cmb2_booking_obj_after_av_dates( CMB2 $cmb ) {
$cmb->add_field( array(
'name' => __('New field title', 'textdomain'),
'desc' => __('field description (optional)', 'textdomain'),
'id' => 'new_field_slug',
'type' => 'text',
) );
}