Field Set field
Purpose
Sub-fields that belong together, e.g. an address with street, city and postcode, read as one array.
Field type name
fieldset
Settings
| Setting | Description |
|---|---|
| Instructions | Help text for editors, shown with the field. |
| Layout | How the sub-fields are arranged for editors. Options: block (Block (fields below each other)), table (Table (fields side by side)), row (Row (labels on the left)). |
| 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
An array of sub-field values keyed by name, in screen order, e.g. [ 'street' => 'Damrak 1', 'city' => 'Amsterdam' ].
Example
$address = cafe_get_field( 'address' );
if ( $address ) {
printf( '%s, %s', esc_html( $address['street'] ), esc_html( $address['city'] ) );
}
// Update only the city; the street keeps its value:
cafe_update_field( 'address', [ 'city' => 'Utrecht' ] );