Text field
Purpose
Single-line plain text: titles, labels, short phrases.
Field type name
text
Settings
| Setting | Description |
|---|---|
| Instructions | Shown to editors below the field label. (max 2000 characters) |
| Default Value | Returned when nothing has been saved yet. |
| Placeholder | Hint shown inside the empty input. (max 255 characters) |
| Prepend | Text shown before the input, e.g. "€". (max 100 characters) |
| Append | Text shown after the input, e.g. "kg". (max 100 characters) |
| Minimum Length | Minimum number of characters. Leave empty for no minimum. (min 0, whole number) |
| Maximum Length | Maximum number of characters. Leave empty for no limit. (min 1, whole number) |
| Translation | How the field behaves in other languages: translate, copy, copy_once or do_not_translate. Used on top-level fields when WPML is active. See WPML. |
| Width | Width on edit screens, to place fields side by side: 100 (full), 75, 66, 50, 33 or 25 (%). Phones always show full width. |
| Label per language | The label and instructions per language code while editing in that language, e.g. {"nl": {"label": "Prijs"}}. Set on the Translation tab when WPML is active. See WPML. |
PHP return value
string, or null when nothing is saved and there is no default.
Example
cafe()->schema_manager()->create_field( $group_id, [
'name' => 'hero_title',
'type' => 'text',
'settings' => [ 'placeholder' => 'Welcome', 'max_length' => 80 ],
] );
echo esc_html( cafe_get_field( 'hero_title' ) );