-
Notifications
You must be signed in to change notification settings - Fork 573
Notable Changes in CMB2
Change 1: The same hooks and filters you're used to will be there, though you'll be required to use the cmb2_
prefix instead of the original cmb_
, and the order and type of parameters passed to those actions have likely changed.
Change 2: The main filter for adding metaboxes, 'cmb2_meta_boxes'
, is still there, but it is recommended that you instead use the registration functions available and use the 'cmb_init'
action hook. You can see them demonstrated in example-functions.php.
Change 3: The old method for including the CMB core files is no longer applicable and you're simply required to include it directly. This is not applicable if installing as a standard WordPress plugin.
Change 4: The 'pages'
metabox parameter has been changed to 'object_types'
to more accurately reflect its purpose, since it will accept post_types as well as other object types like 'user'
, 'comment'
, or 'options-page'
.
Change 5: The 'options'
field parameter for radio and select fields is now created with an id => label key value pairing. i.e.
$cmb->add_field( array(
'name' => __( 'Test Select', 'cmb2' ),
'id' => 'yourprefix_test_select',
'type' => 'select',
'options' => array(
'standard' => __( 'Option One', 'cmb2' ),
'custom' => __( 'Option Two', 'cmb2' ),
'none' => __( 'Option Three', 'cmb2' ),
),
) ),
Documentation:
-
Installation
Installation instructions for various environments -
Basic Usage
Get up and running -
Advanced Usage
Not for the faint of heart -
Field Types
Breakdown of field types -
Examples
Examples for registering fields -
Field Parameters
Breakdown of common field parameters -
Display Options
Limit display of boxes -
Box Properties
Breakdown of box properties -
Troubleshooting
Common issues & how to deal with them -
Notable Changes in CMB2 (from original CMB)
CMB2 — a complete re-write -
Tips & Tricks
10x your CMB2 skills -
REST API
CMB2 data through WordPress REST API -
Javascript API
Work with CMB2 JS events & hooks
Advanced tutorials:
- Adding your own field types
- Adding your own show_on filters
- Displaying boxes on the front-end
- Using CMB to create an Admin Theme Options Page
- Create New Posts (or Custom Post Type) Entries Using A Front End Form
- Disable CMB2 Styles on Front End Forms
External Resources: