Running an older version of CMB? Check the previous releases.
This plugin gives you two CMB field types based on the Select2 script:
- The
pw_select
field acts much like the defaultselect
field. However, it adds typeahead-style search allowing you to quickly make a selection from a large list - The
pw_multiselect
field allows you to select multiple values with typeahead-style search. The values can be dragged and dropped to reorder
You can install this field type as you would a WordPress plugin:
- Download the plugin
- Place the plugin folder in your
/wp-content/plugins/
directory - Activate the plugin in the Plugin dashboard
Alternatively, you can place the plugin folder in with your theme/plugin. After you call CMB:
require_once 'init.php';
Add another line to include the cmb-field-select2.php
file. Something like:
require_once 'cmb-field-select2/cmb-field-select2.php';
pw_select
- Select box with with typeahead-style search. Example:
array(
'name' => 'Cooking time',
'id' => $prefix . 'cooking_time',
'desc' => 'Cooking time',
'type' => 'pw_select',
'options' => array(
'5' => '5 minutes',
'10' => '10 minutes',
'30' => 'Half an hour',
'60' => '1 hour',
),
),
pw_multiselect
- Multi-value select box with drag and drop reordering. Example:
array(
'name' => 'Ingredients',
'id' => $prefix . 'ingredients',
'desc' => 'Select ingredients. Drag to reorder.',
'type' => 'pw_multiselect',
'options' => array(
'flour' => 'Flour',
'salt' => 'Salt',
'eggs' => 'Eggs',
'milk' => 'Milk',
'butter' => 'Butter',
),
),