Skip to content

Instantly share code, notes, and snippets.

@rilwis
Created March 5, 2015 10:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rilwis/452dec0295484a455875 to your computer and use it in GitHub Desktop.
Save rilwis/452dec0295484a455875 to your computer and use it in GitHub Desktop.
Support to migrating data to a group
<?php
$data = array(
array(
'year' => 2013,
'title' => 'Test',
'wins' => 1,
'podiums' => 2,
'poles' => 3,
'description' => 'test description',
),
array(
'year' => 2014,
'title' => 'Test Title 2',
'wins' => 1,
'podiums' => 2,
'poles' => 3,
'description' => 'Test Description 2'
)
);
$post_id = 1;
$group_id = 'group';
update_post_meta( $post_id, $group_id, $data );
<?php
add_filter( 'rwmb_meta_boxes', function( $meta_boxes )
{
$meta_boxes[] = array(
'title' => 'Group Test',
'fields' => array(
array(
'id' => 'group', // Must match $group_id
'name' => 'Group',
'type' => 'group',
'clone' => true,
'fields' => array(
array(
'id' => 'year',
'name' => 'Year',
'type' => 'text',
),
array(
'id' => 'title',
'name' => 'Title',
'type' => 'text',
),
array(
'id' => 'wins',
'name' => 'Wins',
'type' => 'text',
),
array(
'id' => 'podiums',
'name' => 'Podiums',
'type' => 'text',
),
array(
'id' => 'poles',
'name' => 'Poles',
'type' => 'text',
),
array(
'id' => 'description',
'name' => 'Description',
'type' => 'textarea',
),
),
),
),
);
return $meta_boxes;
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment