Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Flexible Field like ACF use Meta Box Plugin
add_filter( 'rwmb_meta_boxes', 'your_prefix_register_meta_boxes' );
function your_prefix_register_meta_boxes( $meta_boxes ) {
$meta_boxes[] = array (
'title' => 'Flexible Field Example',
'id' => 'flexible-field-example',
'post_types' => array(
0 => 'page',
),
'context' => 'normal',
'priority' => 'high',
'fields' => array(
array (
'id' => 'sections',
'type' => 'group',
'name' => 'Sections',
'fields' => array(
array (
'id' => 'select',
'name' => 'Select',
'type' => 'select',
'placeholder' => 'Select an Item',
'options' => array(
'Services' => 'Services',
'Testimonials' => 'Testimonials',
'Facts' => 'Facts',
),
),
array (
'id' => 'services',
'type' => 'group',
'name' => 'Services',
'fields' => array(
array (
'id' => 'secvices_box',
'type' => 'group',
'name' => 'Secvices Box',
'fields' => array(
array (
'id' => 'image',
'type' => 'single_image',
'name' => 'Icon services',
'desc' => 'Transparent background',
),
array (
'id' => 'description',
'type' => 'textarea',
'name' => 'Description',
),
),
'clone' => 1,
'default_state' => 'expanded',
'collapsible' => true,
'group_title' => 'Secvices Box',
),
),
'default_state' => 'expanded',
'collapsible' => true,
'save_state' => true,
'group_title' => 'Services Section',
'visible' => array(
'when' => array(
array (
0 => 'select',
1 => '=',
2 => 'Services',
),
),
'relation' => 'and',
),
),
array (
'id' => 'testimonials',
'type' => 'group',
'name' => 'Testimonials',
'fields' => array(
array (
'id' => 'testimonials_box',
'type' => 'group',
'name' => 'Testimonials Box',
'fields' => array(
array (
'id' => 'image_upload_2',
'type' => 'image_upload',
'name' => 'Image profile',
'max_status' => false,
'max_file_uploads' => 2,
'image_size' => 'thumbnail',
),
array (
'id' => 'Content',
'name' => 'Content',
'type' => 'wysiwyg',
),
),
'default_state' => 'expanded',
),
),
'default_state' => 'expanded',
'collapsible' => true,
'save_state' => true,
'group_title' => 'Testimonials Section',
'visible' => array(
'when' => array(
array (
0 => 'select',
1 => '=',
2 => 'Testimonials',
),
),
'relation' => 'and',
),
),
array (
'id' => 'facts',
'type' => 'group',
'name' => 'Facts',
'fields' => array(
array (
'id' => 'title',
'type' => 'text',
'name' => 'Title Fact',
),
array (
'id' => 'textarea_2',
'type' => 'textarea',
'name' => 'Description Fact',
),
array (
'id' => 'group_2',
'type' => 'group',
'name' => 'Fact Box',
'fields' => array(
array (
'id' => 'text_2',
'type' => 'text',
'name' => 'Title',
),
array (
'id' => 'number_2',
'type' => 'number',
'name' => 'Amount',
),
),
'default_state' => 'expanded',
),
),
'default_state' => 'expanded',
'collapsible' => true,
'group_title' => 'Facts Section',
'visible' => array(
'when' => array(
array (
0 => 'select',
1 => '=',
2 => 'Facts',
),
),
'relation' => 'and',
),
),
),
'clone' => 1,
'default_state' => 'expanded',
'collapsible' => true,
'save_state' => true,
'group_title' => 'Choose which section you want',
),
),
'include' => array(
'relation' => 'OR',
'ID' => 2,
'template' => array(
0 => 'page.php',
),
),
);
return $meta_boxes;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.