Rich Text Editor field
Purpose
Formatted text written with the WordPress editor: headings, bold, lists, links, alignment and (optionally) images from the media library. Use it for body copy, descriptions or any text that needs formatting. For plain text, use Textarea.
Field type name
rich_text
Settings
| Setting | Description |
|---|---|
| Instructions | Shown to editors below the field label. (max 2000 characters) |
| Default Value | Returned when nothing has been saved yet. Basic HTML is allowed. (max 10000 characters) |
| Add Paragraphs | Turn line breaks into paragraphs (wpautop()) when the value is read, like post content. |
| Toolbar | full (headings, lists, alignment, colors, …) or basic (bold, italic, lists, links). |
| Show "Add Media" | Show the Add Media button above the editor. |
| Height | Height of the editor in pixels. (min 100, max 2000, 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. |
toolbar, media_upload and height are on the Presentation tab of the
field editor. Unknown settings are rejected (cafe_unsupported_setting);
invalid values are rejected (cafe_invalid_setting).
PHP return value
string of HTML, with paragraphs added by wpautop() unless auto_paragraphs
is off, or null when nothing is saved and there is no default.
Example
$body = cafe_get_field( 'body' );
if ( $body ) {
echo wp_kses_post( $body );
}
// Inside a Collection:
foreach ( cafe_rows( 'features' ) as $feature ) {
printf( '<h3>%s</h3>%s', esc_html( $feature['title'] ), wp_kses_post( $feature['text'] ) );
}