Skip to content

Instantly share code, notes, and snippets.

@kutoi94
Last active June 9, 2019 00:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kutoi94/1e477351ccec49526c63e7d1d315be94 to your computer and use it in GitHub Desktop.
Save kutoi94/1e477351ccec49526c63e7d1d315be94 to your computer and use it in GitHub Desktop.
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