! " # Login Register MB Meta Box Features Extensions Docs FAQ Support Contact Blog HOME / DOCUMENTATION / BASIC / DEFINE FIELDS Define Fields Each field in a meta box is an array of its own attributes. $ Common field attributes Each field of a meta box can have 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 as meta_key. It s a good practice to use only numbers, chars and underscores. type Field type. See the list below for all supported field types. 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? true or false. Optional. Note that this feature currently works for almost all fields, except file and image fields. $ List of supported field `type` This is the list of all supported field types in the Meta Box plugin with brief description: Fiielld Type Descriiptiion autocomplete Text input that uses jquery autocomplete library to perform the autocomplete action. Added in version 4.4.0. button Display simple button. Usually used for Javascript trigger checkbox Checkbox 1 of 8 18/09/15 12:45
Fiielld Type checkbox_list Descriiptiion List of checkboxes color Color picker date Date picker datetime Date and time picker divider Simple horizontal line file Simple file upload with default UI like <input type="file" />. file_advanced Advanced file upload with UI like WordPress media upload popup. Inherits file file_input Allow to enter URL for a file or select a file from media library (UI like WordPress media upload popup). This field saves file URL as meta value. heading Heading text hidden Input field with hidden type image Similar to file but used for images only. Allow drag and drop to reorder images. Inherits file image_advanced Similar to file_advanced, but used for images only. Inherits image image_select Similar to radio select, but use images instead of radio map Google maps field number Input for numbers which uses new HTML5 input type="number" oembed Input for videos, audios from Youtube, Vimeo and all supported sites by WordPress. It has preview feature. password Password input field plupload_image Image upload field, support drag and drop files. Inherits from image post Select post from select dropdown. Support custom post types. Inherits from select or select_advanced based on field_type parameter radio Radio input range HTML 5 range input select Select dropdown select_advanced Beautiful select dropdown using select2 library. Inherits select slider jquery UI slider field 2 of 8 18/09/15 12:45
Fiielld Type taxonomy Descriiptiion Select taxonomies. Has various to display as check box list, select dropdown (supports simple select and select_advanced UI), tree (select parent taxonomy will show children taxonomies). Note: this field doesn t save term IDs in post meta, instead of that, it only set post terms. taxonomy_advanced Same as taxonomy but saves term IDs in post meta as a comma separated string. It doesn t set post terms. text Text field textarea Textarea field thickbox_image Old image upload using thickbox. Deprecated. time Time picker url HTML 5 URL input user Select dropdown for user, supports simple select and select_advanced UI wysiwyg WordPress editor field $ Attributes for specific field types Besides all common attributes, each field type can have other attributes. This section will describe all attributes for specific field types. Important: 1. The inherited fields can have attributes from their parents. 2. Some fields like post, taxonomy has to display as select, select_advanced or checkbox_list can also inherit attributes from these fields $ Autocomplete array of predefined 'value' => 'Label' pairs. They re used to autocomplete from user input. value is stored in the custom field. Required. size input size. Default 30. Optional. clone allow this field to be cloned? true or false. Default false. Optional. 3 of 8 18/09/15 12:45
Note this field can store multiple values from user inputs $ Checkbox list array of 'value' => 'Label' pairs. value is stored in the custom field and Label is used to display in the meta box. $ Date size size of the input box. Optional. Default 10. js_ jquery date picker. See here, some main are: dateformat : Date format. Optional. Default yy- mm- dd. For the full list of date format, please see here. Note: The format option is deprecated and replaced by this option. showbuttonpanel Show button panel or not? Optional. Default true. (See demo/date- time- js-.php for example). $ Datetime size size of the input box. Optional. Default 20. js_ a combination of date and time for jquery. See date and time fields above. timestamp save datetime in Unix timestamp format (but still display in human-readable format), true or false. Optional. Default false. $ File max_file_uploads Max number of uploaded files. Optional. force_delete Whether or not delete the files from Media Library when deleting them from post meta ( true or false )? Optional. Default false. $ File Advanced 4 of 8 18/09/15 12:45
mime_type Mime type of files which we want to show in Media Library. Note: this is a filter to list items in Media popup, it doesn t restrict file types when upload. $ Map To register a map field, you need to actually register 2 fields: 1 field with type text which stores the address of the map. 1 field with type map. This field has only 1 additional parameter address_field which must have the value the same as the id of the text field above. In addition, you can specify the initial position of the map with std param in the format 'latitude,longitude[,zoom]' ( zoom is optional). See demo file. $ Number step Set the increments at which a numeric value can be set. It can be the string any or a positive floating point number or integer. If this attribute is not set to any, the control accepts only values at multiples of the step value greater than the minimum. Default is 0. Optional. min Minimum value. Default is 0. Optional. placeholder Placeholder for the input field. Optional. $ Radio array of 'value' => 'Label' pairs. value is stored in the custom field and Label is used to display in the meta box. $ Select array of 'value' => 'Label' pairs. value is stored in the custom field and Label is used to display in the dropdown. placeholder instruction text for users to select value, like Please select multiple allow to select multiple values or not. Can be true or false. Optional. Default false. 5 of 8 18/09/15 12:45
$ Select Advanced js_ array of for select2 library. See this documentation for all. By default, Meta Box applies these default for js_ : Attriibute Defaullt Vallue Descriiptiion allowclear true Allow users to clear selection width resolve Set width by element s width placeholder $field['placeholder'] Make placeholder works just like select field $ Taxonomy array of taxonomy : taxonomy : taxonomy name type : how to show taxonomy, can be checkbox_list (default), checkbox_tree, select_tree, select. Optional. args : additional arguments, like in get_terms() function. Optional. $ Text size size of input box. Optional. Default 30. $ Textarea cols number of columns. Optional. Default 60. rows number of rows. Optional. Default 4. $ Time 6 of 8 18/09/15 12:45
size size of input box. Optional. Default 10. js_ jquery date picker. See here, some main are: timeformat : Time format. Optional. Default hh:mm. For full list of time format, please see here. Note The format option is deprecated and replaced by this option. showbuttonpanel : Show button panel or not? Optional. Default true. (See demo/date- time- js-.php for example). $ WYSIWYG (Editor) raw If you want to save data in raw format, e.g. exactly the same as you enter in the editor without applying wpautop() function. Value can be true or false (default). Optional. Array of editor, which is the same as 3rd parameter for wp_editor() function. Please read the Codex for full descriptions of all. By default, the plugin uses 2 : Attriibute Defaullt Vallue Descriiptiion editor_class rwmb- wysiwyg Just to make CSS consistent with other fields dfw true Allow to use Distraction Free Writing mode (full-screen mode) LAST UPDATE: SEPTEMBER 17, 2015 7 of 8 18/09/15 12:45
Grab the core extensions bundle today and save over 60%! Check it out Copyright 2015 Meta Box. All rights reserved. A project by Tran Ngoc Tuan Anh (a.k.a. Rilwis) and friends. 8 of 8 18/09/15 12:45