Skip to content

Instantly share code, notes, and snippets.

@ryelle
Created March 10, 2012 17:18
Show Gist options
  • Select an option

  • Save ryelle/2012181 to your computer and use it in GitHub Desktop.

Select an option

Save ryelle/2012181 to your computer and use it in GitHub Desktop.
Example Custom Meta Boxes use
<?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 );
<?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