Button Group field
Purpose
One choice shown as a row of buttons: "Left | Center | Right", "Small | Medium | Large". Quicker to scan than a dropdown when there are only a few options.
Field type name
button_group
Settings
| Setting | Description |
|---|---|
| Instructions | Shown to editors below the field label. (max 2000 characters) |
| Choices | The options editors can pick. The value is stored; the label is shown. (required) |
| Return Format | What cafe_get_field() returns for a chosen option. |
| Default Value | Choice value returned when nothing has been saved yet. |
| Allow None | Add a "None" button so editors can clear the choice. |
| Layout | horizontal (one row) or vertical (a column). |
| Translation | How the field behaves in other languages: translate, copy, copy_once or do_not_translate. See WPML. |
| Width | Width on edit screens: 100, 75, 66, 50, 33 or 25 (%). |
| Label per language | The label and instructions per language code while editing in that language. See WPML. |
PHP return value
By Return Format: the value, the label, or ['value' => …, 'label' => …]; null
when empty.
Example
$align = cafe_get_field( 'text_align' ) ?? 'left';
echo '<div class="hero hero--' . esc_attr( $align ) . '">';