Skip to content

Textarea

Radoslav Georgiev edited this page Oct 21, 2018 · 2 revisions

Purpose

The textarea field lets your users enter multi-line text content.

textarea-field

Options

Rows

You can adjust the height of a textarea by adjusting the amount ot visible rows. By default it is 8.

In PHP you can use the set_rows method:

Field::create( 'textarea', 'bio' )
	->set_rows( 20 )

Output Settings

Apply the the_content filter

The the_content filter in WordPress allows the core and plugins to modify the content of a post. It comes with many tags/functions already attached to it:

  1. wptexturize
  2. convert_smilies
  3. convert_chars
  4. wpautop
  5. shortcode_unautop
  6. prepend_attachment

This filter will fix special characters, add paragraphs and shortcodes and more.

In PHP, if you want the filter to be applied, use the apply_the_content method. It accepts a single, $flag argument, which allows you to toggle if you want to enable or disable the filter.

This filter could have many hooks attached to itself and could lead to slow performance. Only apply this if really needed.

Field::create( 'textarea', 'bio' )
	->apply_the_content()

Apply Shortcodes

The do_shortcodes function in WordPress converts shortcodes to actual content. Enabling this setting will automatically apply shortcodes when the content of the field is being used.

In PHP, use the do_shortcodes method. It accepts a single, $flag argument, which allows you to toggle if you want to enable or disable the filter.

Field::create( 'bio' )
	->do_shortcodes();

Automatically add paragraphs

The wpautop function in WordPress automatically adds paragraphs to a string. Enabling this setting will automatically add paragraphs to the content of a textarea field when used.

In PHP, use the add_paragraphs method. It accepts a single, $flag argument, which allows you to toggle if you want to enable or disable the filter.

Field::create( 'bio' )
	->add_paragraphs();
Clone this wiki locally