Skip to content

Textarea

A multi-line text input for longer content like descriptions, excerpts, and paragraphs.

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

SettingDescription
Field KeyUnique identifier. Lowercase letters and underscores only.
LabelDisplay label shown above the field.
DescriptionOptional helper text shown below the field.
PlaceholderOptional placeholder text shown inside the empty textarea.
Default ValueOptional value pre-filled when no value has been saved.
RowsNumber 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() after wpautop() — it will escape the HTML tags

On This Page