Skip to content

Instantly share code, notes, and snippets.

@heddesheimer
Created March 13, 2015 16:51
Show Gist options
  • Save heddesheimer/2ab0cff78c2e326a0f0f to your computer and use it in GitHub Desktop.
Save heddesheimer/2ab0cff78c2e326a0f0f to your computer and use it in GitHub Desktop.
Example to show the problem when using file and file_ist on the same page.
add_action( 'cmb2_init', 'yourprefix_register_about_page_metabox' );
function yourprefix_register_about_page_metabox() {
// Start with an underscore to hide fields from custom fields list
$prefix = '_yourprefix_about_';
/**
* Metabox to be displayed on a single page ID
*/
$cmb_about_page = new_cmb2_box( array(
'id' => $prefix . 'metabox',
'title' => __( 'About Page Metabox', 'cmb2' ),
'object_types' => array( 'page', ), // Post type
'context' => 'normal',
'priority' => 'high',
'show_names' => true, // Show field names on the left
) );
$cmb_about_page->add_field( array(
'name' => __( 'Test file', 'cmb2' ),
'desc' => __( 'field description (optional)', 'cmb2' ),
'id' => $prefix . 'image',
'type' => 'file',
) );
$cmb_about_page->add_field( array(
'name' => __( 'Test image list', 'cmb2' ),
'desc' => __( 'field description (optional)', 'cmb2' ),
'id' => $prefix . 'imagelist',
'type' => 'file_list',
) );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment