Textarea Field
The Textarea field is a multi-line text input for longer content — descriptions, excerpts, biography text, or any content that spans multiple lines.
Field Settings
| Setting | Description |
|---|---|
| Field Key | Unique identifier. Lowercase letters and underscores only. |
| Label | Display label shown above the field. |
| Description | Optional helper text shown below the field. |
| Placeholder | Optional placeholder text shown inside the empty textarea. |
| Default Value | Optional value pre-filled when no value has been saved. |
| Rows | Number of visible rows in the textarea (default: 4). |
Return Value
Returns a string. Line breaks are preserved in the raw value.
Usage
php
// Get the value
$content = onemeta_get_meta( get_the_ID(), 'field_key' );
// Display raw with line breaks converted to <br>
echo nl2br( esc_html( $content ) );
// Display as paragraphs (WordPress auto-formatting)
echo wp_kses_post( wpautop( $content ) );
// Display escaped
echo esc_html( $content );
Template Example
php
<?php $bio = onemeta_get_meta( get_the_ID(), 'author_bio' ); ?>
<?php if ( ! empty( $bio ) ) : ?>
<div class="author-bio">
<?php echo wp_kses_post( wpautop( $bio ) ); ?>
</div>
<?php endif; ?>
Notes
- Use
wpautop()to convert double line breaks to<p>tags - Use
nl2br()to convert single line breaks to<br>tags - Use
wp_kses_post()to allow basic HTML while stripping unsafe tags - Do not use
esc_html()afterwpautop()— it will escape the HTML tags