Contents
Overview of Custom Fields Creator
WCK Custom Fields Creator offers an UI for setting up Custom Meta Boxes with Custom Fields for your Posts, Pages or Custom Post Types.
Custom fields are stored as post meta and all the data handling is done with ajax.
After we setup our Custom Meta Box we can use the Custom Field that is attached to our Custom Post Type.
Custom Fields Creator – Meta Box Arguments
For the Custom Meta Box we can set the following Arguments: Group Name, Post Type, Repeater, Sortable, Post ID and Page Template.
Meta Box Arguments:
- Group name (required) – The name of the group. It is the name by which you will query the data in the front-end. Must be unique, only lowercase letters, no spaces and no special characters
- Post Type (required) – What Post Type the Meta Box should be attached to
- Repeater – Whether the Meta Box is a Single Custom Meta Box or Repeater Custom Meta Box. By default it is a Single Meta Box
- Sortable – Whether the entries are sortable or not. This is valid for Repeater Meta Boxes
- Post ID – ID of the post on which the Meta Box should appear
- Page Template – If post type is “page” you can further select a Page Template. The Meta Box will only appear on the page that has that selected Page Template.
Single Custom Meta Boxes and Repeater Custom Meta Boxes
You can create 2 types of Custom Meta Boxes: Single Custom Meta Boxes and Repeater Custom Meta Boxes (for Repeater Custom Fields).
Custom Fields Creator – Meta Box Fields
All the Custom Fields created with CFC are displayed inside a Custom Meta Box.
Custom Fields Arguments:
- Field Title (required) – The title of the custom field
- Field Type (required) – The type of the custom field
- Description – The description of the field
- Required – Whether the field is required or not
- Default value – Default value of the field
Custom Fields Creator – Fields Types
WCK makes it really easy to add Default and Extra Fields Types inside your Custom Meta Box. Under the Meta Box Fields tab, you’ll find an intuitive interface for Adding, Editing, Deleting or Reordering fields.
You can add a field to the Custom Meta Box by simply choosing one of the supported fields from the Field Type drop-down.
Once you select a field type you’ll need to fill in the field properties:
Default Fields Types
All Free and Premium versions of WordPress Creation Kit supports the following Default Fields Types:
- Text – Used to add limited information
- Textarea – Used to add consistent information
- Select – Used to choose data from a predefined list
- Checkbox – Used to check an option from a list
- Radio – Used to select an option from a radio button group
- Upload – Used for uploading Files or Images via the WordPress Media Uploader
- WYSIWYG Editor – Used for adding and editing information with HTML
- Heading – Used to create sections of Custom Fields
- Colorpicker – Allows a color to be selected via a JavaScript popup
- Currency Select – Allows a currency to be selected from a dropdown list
- Phone – Used for adding a phone number
- Timepicker – Used for selecting the hour / minute from a dropdown list
- HTML – Used to add HTML content
- Number – Used to add a number
Extra Fields Types
WordPress Creation Kit, both PRO and Hobbyist versions, supports a wide range of Extra Fields Types:
- Datepicker – Allows a date to be selected via a JavaScript popup calendar
- Country Select – Used to create a dropdown list with all countries
- User Select – Displays a dropdown that lets you select one of the users registered on your website
- Custom Post Type Select – Displays a dropdown of all available entries for a specific Custom Post Type
- Map – Allows to add a Map in a Post, Page or Custom Post Type
Manage existing Custom Fields with WCK
If, before using WCK, you already have a couple of fields attached to Post, Pages or CPTs being saved in the database and want to display and manage them using WCK, all you need to do is create a Meta Box and add each one of them under the Meta Box Fields tab, give them the same meta-name and check the “Overwrite existing” option.
This way you’ll be able to display and update existing fields with WCK.
Reorder Fields
Meta Box Fields provides a Drag & Drop interface for sorting and reordering both default and extra fields.
You’ll be able to easily mix default and extra fields to fit your needs.
This way you don’t need to worry about the order in which you create your Custom Fields. You can always rearrange them to your liking.
Edit or Delete a Field
Editing or deleting a field is done by clicking the Edit or Delete buttons from the fields table.
To add HTML tags inside input fields like the Text field you will need to use the following custom code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | add_filter( 'wck_pre_sanitize_value', 'wck_bypass_default_sanitization' ); function wck_bypass_default_sanitization( $bool ){ return true; } add_filter( 'wck_sanitize_value', 'wck_sanitize_value_change', 10, 2 ); function wck_sanitize_value_change( $value, $meta_name ){ if( is_array( $value ) ) $value = array_map( 'wck_basic_sanitize_value', $value ); else $value = wck_basic_sanitize_value( $value ); return $value; } function wck_basic_sanitize_value( $string ){ return preg_replace( '/<script\b[^>]*>(.*?)<\/script>/is', '', $string ); } |