Last active
September 23, 2015 18:01
-
-
Save ronalfy/a2fc8649139c7bf4188d to your computer and use it in GitHub Desktop.
CMB2 + Customizer
This file contains hidden or 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', function() { | |
$cmb = new_cmb2_box( array( | |
'id' => 'address', | |
'title' => __( 'My Address', 'cmb2' ), | |
'object_types' => 'customizer', // Post type | |
'context' => 'normal', | |
'priority' => 800, | |
'show_names' => true, // Show field names on the left | |
) ); | |
// Regular text field | |
$cmb->add_field( array( | |
'name' => __( 'Street Address', 'cmb2' ), | |
'desc' => __( 'field description (optional)', 'cmb2' ), | |
'id' => 'cmb_street_address', | |
'type' => 'text', | |
) ); | |
// Regular text field | |
$cmb->add_field( array( | |
'name' => __( 'File', 'cmb2' ), | |
'desc' => __( 'field description (optional)', 'cmb2' ), | |
'id' => 'cmb_file_1', | |
'type' => 'file', | |
) ); | |
// Regular text field | |
$cmb->add_field( array( | |
'name' => __( 'Text URL', 'cmb2' ), | |
'desc' => __( 'field description (optional)', 'cmb2' ), | |
'id' => 'cmb_text_url', | |
'type' => 'text_url', | |
) ); | |
// Regular text field | |
$cmb->add_field( array( | |
'name' => __( 'Text File', 'cmb2' ), | |
'desc' => __( 'field description (optional)', 'cmb2' ), | |
'id' => 'cmb_file_2', | |
'type' => 'file', | |
) ); | |
// Regular text field | |
$cmb->add_field( array( | |
'name' => __( 'Color', 'cmb2' ), | |
'desc' => __( 'field description (optional)', 'cmb2' ), | |
'id' => 'cmb_color', | |
'type' => 'colorpicker', | |
) ); | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment