Created
March 13, 2015 16:51
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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