Support Forum
Hi there,
Need some help to fix a metabox bug changing the values of the fields after I save the page.
screenshot in here: https://www.evernote.com/shard/s332/sh/b6704fb4-5066-4801-ac0b-45f9a86358d3/4295ea47d7da5ab3
The user needs to be able to select from which "Event Type" to show events from, the problem now is even if the user selects event A (example) for the first event type and event B for the second one after you save the page changes it automatically change both of the event type dropdown to the event B.
Please let me know any help with this, bit of urgency on this.
Code below:
add_filter( 'rwmb_meta_boxes', 'page_events_meta_two_boxes' );
function page_events_meta_two_boxes( $meta_boxes )
{
$prefix = 'thspep_two_';
// page event meta box
$meta_boxes[] = array(
'id' => 'page_events_two',
'title' => 'Sencond Page Events Custom Fields',
'post_types' => 'page',
'context' => 'normal',
'priority' => 'high',
'fields' => array(
array(
'type' => 'heading',
'name' => __( 'Second Event Type Section', 'your-prefix' ),
'id' => 'fake_id', // Not used but needed for plugin
'columns' => 12,
),
array(
'name' => 'Second Event Type',
'id' => $prefix . 'event_type_option',
'type' => 'taxonomy',
'taxonomy' => 'event-type',
'field_type' => 'select_advanced',
'columns' => 6,
),
array(
'name' => 'Second Feature Points',
'id' => $prefix . 'feature_points',
'type' => 'text',
'clone' => true,
'sort_clone' => true,
'columns' => 6,
),
),
);
return $meta_boxes;
}
add_filter( 'rwmb_meta_boxes', 'page_events_meta_boxes' );
function page_events_meta_boxes( $meta_boxes )
{
$prefix = 'thspe_';
// page event meta box
$meta_boxes[] = array(
'id' => 'page_events',
'title' => 'Page Events Custom Fields',
'post_types' => 'page',
'context' => 'normal',
'priority' => 'high',
'fields' => array(
// Event Type Section
array(
'type' => 'heading',
'name' => __( 'Event Type Section', 'your-prefix' ),
'id' => 'fake_id', // Not used but needed for plugin
'columns' => 12,
),
array(
'name' => 'Event Module Headline',
'id' => $prefix . 'events_module_title',
'type' => 'text',
'columns' => 12,
),
array(
'name' => 'Event Type',
'id' => $prefix . 'event_type_option',
'type' => 'taxonomy',
'taxonomy' => 'event-type',
'field_type' => 'select_advanced',
'columns' => 6,
),
array(
'name' => 'Information Sessions Listing Points',
'id' => $prefix . 'info_session_listing',
'type' => 'text',
'clone' => true,
'sort_clone' => true,
'columns' => 6,
),
),
);
return $meta_boxes;
}
Hi there,
You must set different ids for 2 event type settings.
Hi,
just tried that, still doesn't work.
1.
array(
'name' => 'Event Type',
'id' => $prefix . 'event_type_option',
'type' => 'taxonomy',
'taxonomy' => 'event-type',
'field_type' => 'select_advanced',
'columns' => 6,
),
2.
array(
'name' => 'Second Event Type',
'id' => $prefix . 'event_type_option_2',
'type' => 'taxonomy',
'taxonomy' => 'event-type',
'field_type' => 'select_advanced',
'columns' => 6,
),
let me know any help, please.
As soon as I save the page the 1st one returns to the same value as the 2nd one.
Hi,
Please use the taxonomy_advanced
field. You can read more here: https://metabox.io/docs/define-fields/#section-taxonomy
Taxonomy field does NOT save term IDs in post meta, instead of that, it only set post terms.
Taxonomy advanced field saves term IDs in post meta as a comma separated string. It does NOT set post terms.