From b4b8a557a642f8c4f1fec54a53b0781c9af809d9 Mon Sep 17 00:00:00 2001 From: Justin Sternberg Date: Sat, 30 May 2015 22:53:04 -0400 Subject: [PATCH] clean up and update example-field-setup.php --- example-field-setup.php | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/example-field-setup.php b/example-field-setup.php index a42766b..3891b47 100644 --- a/example-field-setup.php +++ b/example-field-setup.php @@ -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.
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.
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' );