WP frontend output of custom textarea fields not respecting line breaks. In admin it’s OK

Explode your $options value by “/n” ( new line ), then do a echo in foreach:

$options = get_option('my_custom_plugin_options');
$textarea = $options['my_custom_plugin_options_textarea'];
$lines = explode("\n", $textarea);

foreach( $lines as $line ){
  echo $line;
}

UPDATE #1

For reference, it’s possible to store this function in functions.php to use later in template files.

function the_textarea_value( $textarea ){
        $lines = explode("\n", $textarea);
        foreach( $lines as $line ){
          echo $line;
        }
}

hope it helps!

Leave a Comment