Created
March 10, 2012 17:18
-
-
Save ryelle/2012181 to your computer and use it in GitHub Desktop.
Example Custom Meta Boxes use
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
| <?php | |
| // Initialize the metabox class | |
| function be_initialize_cmb_meta_boxes() { | |
| if ( !class_exists( 'cmb_Meta_Box' ) ) { | |
| require_once( 'libs/cmb-library/init.php' ); | |
| } | |
| } add_action( 'init', 'be_initialize_cmb_meta_boxes', 9999 ); |
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
| <?php | |
| // get CMB library here: https://github.com/jaredatch/Custom-Metaboxes-and-Fields-for-WordPress | |
| function kd_example_sidebar_metaboxes( $meta_boxes ) { | |
| $meta_boxes[] = array( | |
| 'id' => 'sidebar_metabox', | |
| 'title' => 'Sidebar', //this is the metabox, the field container. | |
| 'pages' => array('page','post','event'), // post type | |
| 'context' => 'normal', | |
| 'priority' => 'high', | |
| 'show_names' => false, | |
| 'fields' => array( //this array contains the fields inside the container. | |
| array( | |
| 'name' => 'Sidebar', | |
| 'id' => 'sidebar', | |
| 'type' => 'wysiwyg', | |
| 'options' => array( | |
| 'textarea_rows' => 3, | |
| ) | |
| ), | |
| ) | |
| ); | |
| return $meta_boxes; | |
| } add_filter( 'cmb_meta_boxes', 'kd_example_sidebar_metaboxes' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment