Types Fields API
To insert Types fields using PHP code, use the following syntax:
For Post fields
<?php echo(types_render_field( "field-slug", array( "arg1" => "val1", "arg2" => "val2" ) )); ?>
Learn more about displaying WordPress custom fields.
For User fields
<?php echo(types_render_usermeta_field( "field-slug", array( "arg1" => "val1", "arg2" => "val2" ) )); ?>
Learn more about displaying WordPress user fields.
Example – Inserting an image field
The following code will insert an image field, called ‘product_image’, while specifying the ALT text, width and height and keeping the image proportional.
For Post fields
<?php echo(types_render_field( "product_image", array( "alt" => "Product image", "width" => "300", "height" => "200", "proportional" => "true" ) )); ?>
For User fields
<?php echo(types_render_usermeta_field( "product_image", array( "alt" => "Product image", "width" => "300", "height" => "200", "proportional" => "true" ) )); ?>
Important note:
The field name is as it appears in Types GUI – not the actual name of the field in the database. This is the ‘simple’ name, without the wpcf prefix.
The list below details the different arguments available for each field.
Raw output
All Types custom fields have an optional ‘raw’ display mode. When you set “raw”=>”true”, Types outputs the value of the field from the database, without any processing. This means that any other attributes will be ignored.
Class and Style
You can specify class and style arguments to all custom fields (except ‘date’ field). The ‘style’ argument receives CSS and the ‘class’ argument can hold the CSS class that you want to assign to the custom field.
Checkbox |
|
|---|---|
| Description: | Displays a checkbox to the user. Checkboxes can be used to get binary, yes/no responses from a user. |
| Rendering: | The "Value to stored" for the checkbox the front end if the checkbox is checked or ‘Selected’|'Not selected’ HTML will be rendered. If ‘Selected’|'Not selected’ HTML is not specified then nothing is rendered. |
| Parameters: | ‘raw’ => ‘true’|'false’ (display raw data stored in DB, default false) ‘output’ => ‘html’ (wrap data in HTML, optional) ‘show_name’ => ‘true’ (show field name before value e.g. My checkbox: $value) ‘state’ => ‘checked’ or ‘unchecked’ (display the content of the shortcode depending on the state) |
| Parameters for post custom fields: |
‘field’ => name of the Types custom field for the post |
| Parameters for user meta fields: |
‘usermeta’ => name of the Types meta field for the user ‘user_id’ => show the user meta field for the user with this id ‘user_name’ => show the user meta field for the user with this user name ‘user_is_author’ => ‘true’, show user meta field for post author ‘user_current’ => ‘true’, show user meta field for current logged in user |
| Example usage: | With a short code use [types field="my-checkbox"] In a theme use types_render_field("my-checkbox", $parameters) Shortcode for user fields [types usermeta=”my-checkbox” user_id=”1″] In a theme use types_render_usermeta_field(“my-checkbox”, $parameters) |
| More details: | Types checkbox custom field |
| File name: | checkbox.php |
Checkboxes |
|
|---|---|
| Description: | Displays a checkbox to the user. Checkboxes can be used to get binary, yes/no responses from a user. |
| Rendering: | The "Value to stored" for the checkbox the front end if the checkbox is checked or ‘Selected’|'Not selected’ HTML will be rendered. If ‘Selected’|'Not selected’ HTML is not specified then nothing is rendered. |
| Parameters: | ‘raw’ => ‘true’|'false’ (display raw data stored in DB, default false) ‘output’ => ‘html’ (wrap data in HTML, optional) ‘show_name’ => ‘true’ (show field name before value e.g. My checkbox: $value) |
| Parameters for post custom fields: |
‘field’ => name of the Types custom field for the post |
| Parameters for user meta fields: |
‘usermeta’ => name of the Types meta field for the user ‘user_id’ => show the user meta field for the user with this id ‘user_name’ => show the user meta field for the user with this user name ‘user_is_author’ => ‘true’, show user meta field for post author ‘user_current’ => ‘true’, show user meta field for current logged in user |
| Example usage: | With a short code use [types field="my-checkboxes"] In a theme use types_render_field("my-checkboxes", $parameters) Shortcode for user fields [types usermeta=”my-checkboxes” user_id=”1″] In a theme use types_render_usermeta_field(“my-checkboxes”, $parameters) |
| File name: | checkboxes.php |
Date |
|
|---|---|
| Description: | Displays a datepicker to the user with optional ‘hour’ and ‘minute’ selection. |
| Rendering: | Date is stored in seconds (time()) but displayed as date formatted. Additional data like ‘hour’ and ‘minute’ is stored in separate meta value. |
| Parameters: | ‘raw’ => ‘true’|'false’ (display raw data stored in DB, default false) ‘output’ => ‘html’ (wrap data in HTML, optional) ‘show_name’ => ‘true’ (show field name before value e.g. My date: $value) ‘style’ => ‘text’|'calendar’ (display text or WP calendar) ‘format’ => defaults to WP date format settings, can be any valid date format e.g. "j/n/Y" or "j/n/Y H:i" |
| Parameters for post custom fields: |
‘field’ => name of the Types custom field for the post |
| Parameters for user meta fields: |
‘usermeta’ => name of the Types meta field for the user ‘user_id’ => show the user meta field for the user with this id ‘user_name’ => show the user meta field for the user with this user name ‘user_is_author’ => ‘true’, show user meta field for post author ‘user_current’ => ‘true’, show user meta field for current logged in user |
| Example usage: | With a short code use [types field="my-date"] Display only hour and minute [types field="my-date" format="H:i"] In a theme use types_render_field("my-date", $parameters) Shortcode for user fields [types usermeta=”my-date” user_id=”1″] In a theme use types_render_usermeta_field(“my-date”, $parameters) |
| File name: | date.php |
|
|
|
|---|---|
| Description: | Displays a email input to the user. |
| Rendering: | Link with mailto as href. Link text can be specified otherwise equals to email address. |
| Parameters: | ‘raw’ => ‘true’|'false’ (display raw data stored in DB, default false) ‘output’ => ‘html’ (wrap data in HTML, optional) ‘show_name’ => ‘true’ (show field name before value e.g. My date: $value) ‘title’ => link title e.g. ‘Mail me!’ |
| Parameters for post custom fields: |
‘field’ => name of the Types custom field for the post |
| Parameters for user meta fields: |
‘usermeta’ => name of the Types meta field for the user ‘user_id’ => show the user meta field for the user with this id ‘user_name’ => show the user meta field for the user with this user name ‘user_is_author’ => ‘true’, show user meta field for post author ‘user_current’ => ‘true’, show user meta field for current logged in user |
| Example usage: | With a short code use [types field="my-email"] In a theme use types_render_field("my-email", $parameters) Shortcode for user fields [types usermeta=”my-email” user_id=”1″] In a theme use types_render_usermeta_field(“my-email”, $parameters) |
| File name: | email.php |
File |
|
|---|---|
| Description: | Displays a file upload or input to the user. |
| Rendering: | Raw DB data (file URI) or link to file. |
| Parameters: | ‘raw’ => ‘true’|'false’ (display raw data stored in DB, default false) ‘output’ => ‘html’ (wrap data in HTML, optional) ‘show_name’ => ‘true’ (show field name before value e.g. My date: $value) ‘link’ => ‘true’|'false’ ‘title’ => link title (‘link’ parameter must be ‘true’) e.g. ‘Download’ |
| Parameters for post custom fields: |
‘field’ => name of the Types custom field for the post |
| Parameters for user meta fields: |
‘usermeta’ => name of the Types meta field for the user ‘user_id’ => show the user meta field for the user with this id ‘user_name’ => show the user meta field for the user with this user name ‘user_is_author’ => ‘true’, show user meta field for post author ‘user_current’ => ‘true’, show user meta field for current logged in user |
| Example usage: | With a short code use [types field="my-file"] In a theme use types_render_field("my-file", $parameters) Shortcode for user fields [types usermeta=”my-file” user_id=”1″] In a theme use types_render_usermeta_field(“my-file”, $parameters) |
| File name: | file.php |
Image |
|
|---|---|
| Description: | Displays a file (image) upload or input to the user. |
| Rendering: | Raw DB data (image URI) or HTML formatted image. |
| Parameters: | ‘raw’ => ‘true’|'false’ (display raw data stored in DB, default false) ‘output’ => ‘html’ (wrap data in HTML, optional) ‘show_name’ => ‘true’ (show field name before value e.g. My date: $value) ‘alt’ => alternative text e.g. ‘My image’ ‘title’ => hover text e.g. ‘My image’ ‘size’ => ‘thumbnail’|'medium’|'large’|'full’ (WP predefined sizes) ‘width’ => image width e.g. 300 (overriden if ‘size’ is specified) ‘height’ => image height e.g. 100 (overriden if ‘size’ is specified) ‘proportional’ => ‘true’|'false’ (overriden if ‘size’ is specified) ‘url’ => ‘true’|'false’ – When true it will output the url of the image instead of the img tag. Works with the size parameter to output the url of the re-sized image |
| Parameters for post custom fields: |
‘field’ => name of the Types custom field for the post |
| Parameters for user meta fields: |
‘usermeta’ => name of the Types meta field for the user ‘user_id’ => show the user meta field for the user with this id ‘user_name’ => show the user meta field for the user with this user name ‘user_is_author’ => ‘true’, show user meta field for post author ‘user_current’ => ‘true’, show user meta field for current logged in user |
| Example usage: | With a short code use [types field="my-image"] Output url of thumbnail image [types field="my-image" size="thumbnail" url="true"] In a theme use types_render_field("my-image", $parameters) Shortcode for user fields [types usermeta=”my-image” user_id=”1″] In a theme use types_render_usermeta_field(“my-image”, $parameters) |
| File name: | image.php |
Numeric |
|
|---|---|
| Description: | Displays a text input to user but forces numeric value to be entered. |
| Rendering: | Raw DB data or HTML formatted output. Also predefined values can be used to set rendering – FIELD_NAME and FIELD_VALUE. This works similar to sprintf() PHP function. |
| Parameters: | ‘raw’ => ‘true’|'false’ (display raw data stored in DB, default false) ‘output’ => ‘html’ (wrap data in HTML, optional) ‘show_name’ => ‘true’ (show field name before value e.g. My date: $value) ‘format’ => e.g. ‘Value of FIELD_NAME is FIELD_VALUE’ FIELD_NAME will be replaced with field name FIELD_VALUE will be replaced with field value |
| Parameters for post custom fields: |
‘field’ => name of the Types custom field for the post |
| Parameters for user meta fields: |
‘usermeta’ => name of the Types meta field for the user ‘user_id’ => show the user meta field for the user with this id ‘user_name’ => show the user meta field for the user with this user name ‘user_is_author’ => ‘true’, show user meta field for post author ‘user_current’ => ‘true’, show user meta field for current logged in user |
| Example usage: | With a short code use [types field="my-numeric"] In a theme use types_render_field("my-numeric", $parameters) Shortcode for user fields [types usermeta=”my-numeric” user_id=”1″] In a theme use types_render_usermeta_field(“my-numeric”, $parameters) |
| File name: | numeric.php |
Phone |
|
|---|---|
| Description: | Displays a text input for user. |
| Rendering: | Raw DB data. |
| Parameters: | ‘raw’ => ‘true’|'false’ (display raw data stored in DB, default false) ‘output’ => ‘html’ (wrap data in HTML, optional) ‘show_name’ => ‘true’ (show field name before value e.g. My date: $value) |
| Parameters for post custom fields: |
‘field’ => name of the Types custom field for the post |
| Parameters for user meta fields: |
‘usermeta’ => name of the Types meta field for the user ‘user_id’ => show the user meta field for the user with this id ‘user_name’ => show the user meta field for the user with this user name ‘user_is_author’ => ‘true’, show user meta field for post author ‘user_current’ => ‘true’, show user meta field for current logged in user |
| Example usage: | With a short code use [types field="my-phone"] In a theme use types_render_field("my-phone", $parameters) NOTICE |
| File name: | phone.php |
Radio |
|
|---|---|
| Description: | Displays a radio selection to the user. |
| Rendering: | The option title will be rendered or if set – specific value. |
| Parameters: | ‘raw’ => ‘true’|'false’ (display raw data stored in DB, default false) ‘output’ => ‘html’ (wrap data in HTML, optional) ‘show_name’ => ‘true’ (show field name before value e.g. My checkbox: $value) |
| Parameters for post custom fields: |
‘field’ => name of the Types custom field for the post |
| Parameters for user meta fields: |
‘usermeta’ => name of the Types meta field for the user ‘user_id’ => show the user meta field for the user with this id ‘user_name’ => show the user meta field for the user with this user name ‘user_is_author’ => ‘true’, show user meta field for post author ‘user_current’ => ‘true’, show user meta field for current logged in user |
| Example usage: | With a short code use [types field="my-radios"] In a theme use types_render_field("my-radios", $parameters) Shortcode for user fields [types usermeta=”my-radio” user_id=”1″] In a theme use types_render_usermeta_field(“my-radio”, $parameters) |
| File name: | radio.php |
Select |
|
|---|---|
| Description: | Displays a select box to the user. |
| Rendering: | The option title will be rendered or if set – specific value. |
| Parameters: | ‘raw’ => ‘true’|'false’ (display raw data stored in DB, default false) ‘output’ => ‘html’ (wrap data in HTML, optional) ‘show_name’ => ‘true’ (show field name before value e.g. My checkbox: $value) |
| Parameters for post custom fields: |
‘field’ => name of the Types custom field for the post |
| Parameters for user meta fields: |
‘usermeta’ => name of the Types meta field for the user ‘user_id’ => show the user meta field for the user with this id ‘user_name’ => show the user meta field for the user with this user name ‘user_is_author’ => ‘true’, show user meta field for post author ‘user_current’ => ‘true’, show user meta field for current logged in user |
| Example usage: | With a short code use [types field="my-select"] In a theme use types_render_field("my-select", $parameters) Shortcode for user fields [types usermeta=”my-select” user_id=”1″] In a theme use types_render_usermeta_field(“my-select”, $parameters) |
| File name: | select.php |
Skype |
|
|---|---|
| Description: | Displays input for skype button. |
| Rendering: | Skype button. |
| Parameters: | ‘raw’ => ‘true’|'false’ (display raw data stored in DB, default false) ‘output’ => ‘html’ (wrap data in HTML, optional) ‘show_name’ => ‘true’ (show field name before value e.g. My checkbox: $value) ‘style’ => ‘btn1′|’btn2′|’btn3′|’btn4′|’btn5′|’btn6′ |
| Parameters for post custom fields: |
‘field’ => name of the Types custom field for the post |
| Parameters for user meta fields: |
‘usermeta’ => name of the Types meta field for the user ‘user_id’ => show the user meta field for the user with this id ‘user_name’ => show the user meta field for the user with this user name ‘user_is_author’ => ‘true’, show user meta field for post author ‘user_current’ => ‘true’, show user meta field for current logged in user |
| Example usage: | With a short code use [types field="my-skype"] In a theme use types_render_field("my-skype", $parameters) Shortcode for user fields [types usermeta=”my-skype” user_id=”1″] In a theme use types_render_usermeta_field(“my-skype”, $parameters) |
| File name: | skype.php |
Textarea |
|
|---|---|
| Description: | Displays a textarea input to the user. |
| Rendering: | HTML formatted DB data. |
| Parameters: | ‘raw’ => ‘true’|'false’ (display raw data stored in DB, default false) ‘output’ => ‘html’ (wrap data in HTML, optional) ‘show_name’ => ‘true’ (show field name before value e.g. My checkbox: $value) |
| Parameters for post custom fields: |
‘field’ => name of the Types custom field for the post |
| Parameters for user meta fields: |
‘usermeta’ => name of the Types meta field for the user ‘user_id’ => show the user meta field for the user with this id ‘user_name’ => show the user meta field for the user with this user name ‘user_is_author’ => ‘true’, show user meta field for post author ‘user_current’ => ‘true’, show user meta field for current logged in user |
| Example usage: | With a short code use [types field="my-textarea"] In a theme use types_render_field("my-textarea", $parameters) Shortcode for user fields [types usermeta=”my-textarea” user_id=”1″] In a theme use types_render_usermeta_field(“my-textarea”, $parameters) |
| File name: | textarea.php |
Texfield |
|
|---|---|
| Description: | Displays a textfield input to the user. |
| Rendering: | HTML formatted DB data. |
| Parameters: | ‘raw’ => ‘true’|'false’ (display raw data stored in DB, default false) ‘output’ => ‘html’ (wrap data in HTML, optional) ‘show_name’ => ‘true’ (show field name before value e.g. My checkbox: $value) |
| Parameters for post custom fields: |
‘field’ => name of the Types custom field for the post |
| Parameters for user meta fields: |
‘usermeta’ => name of the Types meta field for the user ‘user_id’ => show the user meta field for the user with this id ‘user_name’ => show the user meta field for the user with this user name ‘user_is_author’ => ‘true’, show user meta field for post author ‘user_current’ => ‘true’, show user meta field for current logged in user |
| Example usage: | With a short code use [types field="my-textfield"] In a theme use types_render_field("my-textfield", $parameters) Shortcode for user fields [types usermeta=”my-texfield” user_id=”1″] In a theme use types_render_usermeta_field(“my-texfield”, $parameters) |
| File name: | textfield.php |
URL |
|
|---|---|
| Description: | Displays a URL input to the user and forces input check. |
| Rendering: | HTML formatted DB data (link). |
| Parameters: | ‘raw’ => ‘true’|'false’ (display raw data stored in DB, default false) ‘output’ => ‘html’ (wrap data in HTML, optional) ‘show_name’ => ‘true’ (show field name before value e.g. My checkbox: $value) ‘title’ => link title e.g. ‘Go here’ ‘class’ => CSS class applied to link e.g. ‘my-link’ ‘no_protocol’ => ‘true’|'false’ (display URL without protocol "http:// and https://", default false) |
| Parameters for post custom fields: |
‘field’ => name of the Types custom field for the post |
| Parameters for user meta fields: |
‘usermeta’ => name of the Types meta field for the user ‘user_id’ => show the user meta field for the user with this id ‘user_name’ => show the user meta field for the user with this user name ‘user_is_author’ => ‘true’, show user meta field for post author ‘user_current’ => ‘true’, show user meta field for current logged in user |
| Example usage: | With a short code use [types field="my-url"] In a theme use types_render_field("my-url", $parameters) Shortcode for user fields [types usermeta=”my-url” user_id=”1″] In a theme use types_render_usermeta_field(“my-url”, $parameters) |
| File name: | url.php |
WYSIWYG |
|
|---|---|
| Description: | Displays a WYSIWYG editor to the user. |
| Rendering: | HTML formatted DB data. |
| Parameters: | ‘raw’ => ‘true’|'false’ (display raw data stored in DB, default false) ‘output’ => ‘html’ (wrap data in HTML, optional) ‘show_name’ => ‘true’ (show field name before value e.g. My checkbox: $value) |
| Parameters for post custom fields: |
‘field’ => name of the Types custom field for the post |
| Parameters for user meta fields: |
‘usermeta’ => name of the Types meta field for the user ‘user_id’ => show the user meta field for the user with this id ‘user_name’ => show the user meta field for the user with this user name ‘user_is_author’ => ‘true’, show user meta field for post author ‘user_current’ => ‘true’, show user meta field for current logged in user |
| Example usage: | With a short code use [types field="my-wysiwyg"] In a theme use types_render_field("my-wysiwyg", $parameters) Shortcode for user fields [types usermeta=”my-wysiwyg” user_id=”1″] In a theme use types_render_usermeta_field(“my-wysiwyg”, $parameters) |
| File name: | wysiwyg.php |
Toolset Free Trial – Learn by Experimenting
Want to learn how to build WordPress sites easier? Now you can, risk-free!
Toolset development team invites you to create a free private test site, with Types, Views, CRED and Access installed and pre-configured. Launch your own real estate, e-commerce or magazine sites on our training server. It’s free and takes a minute.

English
Français
Deutsch
Español