Common attributes
Meta box has 30 field types:
- checkbox
- checkbox_list
- color
- date
- datetime
- file
- file_advanced
- hidden
- image
- image_advanced
- map
- number
- oembed
- password
- plupload_image
- post
- radio
- range
- select
- select-advanced
- slider
- taxonomy
- text
- textarea
- thickbox_image
- time
- url
- wysiwyg
Each field of a meta box has the following attributes:
name: name of the custom field. It’ll be displayed in the meta box. Required.id: id of the field. Required. Must be unique. It will be used asmeta_key. It’s a good practice to use only numbers, chars and underscores.type: field type, can be one oftext,textarea,checkbox,checkbox list,radio,select,wysiwyg,file,image,date,time,color. Required.desc: a short description explaining what it is. Optional.std: default value of the custom field. Optional.class: custom CSS class, in case you want to style the field the way you want. Optional.clone: is the field clonable?trueorfalse. Optional. Note that this feature currently works for some fields only:text,textarea,radio.
These attributes can be used for all fields. Depends on field type, each field can has its different parameters and meaning.
Text
size: size of input box. Optional. Default: 30.
Textarea
textarea has 2 more parameters:
cols: number of columns. Optional. Default: 60.rows: number of rows. Optional. Default: 4.
Radio
options: array of'value' => 'Label'pairs.valueis stored in custom field andLabelis used to display in the meta box.
Select
options: array of'value' => 'Label'pairs.valueis stored in custom field andLabelis used to display in the dropdown.multiple: allow to select multiple values or not. Can betrueorfalse. Optional. Default:false.
Date
size: size of input box. Optional. Default: 10.js_options: jQuery date picker options. See here, some main options are:dateFormat: Date format. Optional. Default:yy-mm-dd. For full list of date format, please see here. Note: Theformatoption is deprecated and replaced by this option.showButtonPanel: Show button panel or not? Optional. Default: true.
(See demo/date-time-js-options.php for example).
Time
size: size of input box. Optional. Default: 10.js_options: jQuery date picker options. See here, some main options are:timeFormat: Time format. Optional. Default:hh:mm. For full list of time format, please see here. Note: Theformatoption is deprecated and replaced by this option.showButtonPanel: Show button panel or not? Optional. Default: true.
(See demo/date-time-js-options.php for example).
Datetime
size: size of input box. Optional. Default: 20.js_options: a combination of date options and time options for jQuery. Seedateandtimefields above.
Checkbox list
options: array of'value' => 'Label'pairs.valueis stored in custom field andLabelis used to display in the meta box.
Plupload image
max_file_uploads: max number of uploaded files. Optional.
Taxonomy
options: array of taxonomy options:taxonomy: taxonomy nametype: how to show taxonomy:checkbox_list,checkbox_tree,select_tree,select. Optional. Default:checkbox_list.args: additional arguments, like inget_terms()function. Optional.