Skip to content

Commit

Permalink
clean up and update example-field-setup.php
Browse files Browse the repository at this point in the history
  • Loading branch information
jtsternberg committed May 31, 2015
1 parent 2913318 commit b4b8a55
Showing 1 changed file with 13 additions and 20 deletions.
33 changes: 13 additions & 20 deletions example-field-setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,33 +23,26 @@ function cmb2_attached_posts_field_metaboxes_example() {
// Start with an underscore to hide fields from custom fields list
$prefix = '_attached_cmb2_';

$example_meta = new_cmb2_box(array(
'id' => 'cmb2_attached_posts_field',
'title' => __( 'Attached Posts', 'cmb2' ),
'object_types' => array( 'page' ), // Post type
'context' => 'normal',
'priority' => 'high',
'show_names' => false, // Show field names on the left
));

$example_meta->add_field(array(
'name' => __( 'Posts', 'cmb2' ),
'id' => 'cmb_attached_posts',
'type' => 'custom_attached_posts',
'desc' => __( 'Drag posts from the left column to the right column to attach them to this page.<br />You may rearrange the order of the posts in the right column by dragging and dropping.', 'cmb2' )
));

$example_meta->add_field(array(
'name' => __( 'Posts', 'cmb2' ),
$example_meta = new_cmb2_box( array(
'id' => 'cmb2_attached_posts_field',
'title' => __( 'Attached Posts', 'cmb2' ),
'object_types' => array( 'page' ), // Post type
'context' => 'normal',
'priority' => 'high',
'show_names' => false, // Show field names on the left
) );

$example_meta->add_field( array(
'name' => __( 'Attached Posts', 'cmb2' ),
'desc' => __( 'Drag posts from the left column to the right column to attach them to this page.<br />You may rearrange the order of the posts in the right column by dragging and dropping.', 'cmb2' ),
'id' => $prefix . 'attached_posts',
'type' => 'custom_attached_posts',
'options' => array(
'show_thumbnails' => true, // Show thumbnails on the left
'filter_boxes' => true, // Show a text box for filtering the results
'query_args' => array( 'posts_per_page' => 10 ), // override the get_posts args
)
));
) );

/* End CMB for Pages */
}
add_action( 'cmb2_init', 'cmb2_attached_posts_field_metaboxes_example' );

0 comments on commit b4b8a55

Please sign in to comment.