-
Notifications
You must be signed in to change notification settings - Fork 124
Create a Meta Box
mattheu edited this page Apr 12, 2013
·
15 revisions
The current method for adding your own meta boxes is to use the 'cmb_meta_boxes' filter to add your own meta box to the array of meta boxes.
Note that A change is planned that will make this process simpler, although backwards compatability will be maintained.
Each meta box can be created by using the arguments listed below.
- id (string) (required) HTML 'id' attribute of the meta box.
- title (string) (required) Title of the edit screen section, visible to user
- pages (string) (required) The type of Write screen on which to show the meta box (eg 'post', 'page')
- fields (array) (required) An array of fields that will be added to the meta box.
- context (string) (optional) The part of the page where the edit screen section should be shown ('normal', 'advanced', or 'side'). Default: 'advanced'
- priority (string) (optional) The priority within the context where the boxes should show ('high', 'core', 'default' or 'low')
add_filter( 'cmb_meta_boxes', 'cmb_sample_metaboxes' );
function cmb_sample_metaboxes( array $meta_boxes ) {
$meta_boxes[] = array(
'title' => 'CMB Test - all fields',
'pages' => 'post',
'context' => 'normal',
'priority' => 'high',
'fields' => $fields // an array of fields - see individual field documentation.
);
return $meta_boxes;
}
- Setup/Install Custom Meta Boxes
- Creating a custom meta box
- Displaying Field Data
- Optional Generic Field Args
- Repeatable Fields
General
- Text Field
- Small Text Field
- Number Field
- URL Field
- Textarea Field
- Code Field
- Select Field
- Checkbox Input Field
- Radio Input Field
Date & Time
WordPress
Media
Utilities