Search code examples
phpwordpressadvanced-custom-fields

Add /n to text in Wordpress (ACF)


I have situation where my output from Textarea field (acf) needs to be like this::

lorem ipsum blabla\nblbala\n\nlorem lorem

This is my ACF text field:

<?php the_field( 'content_new' ); ?>

this returns content like this:

lorem ipsum blabla <br> 
blbala <br> nlorem lorem

So my question is, can I output /n instead of <br> like on example:

lorem ipsum blabla\nblbala\n\nlorem lorem

Thank you all


Solution

  • First of all check that your textarea field setting new lines is set to "No formatting"

    Also you can do this

    <?php echo str_replace('<br>', '\n', get_field( 'content_new' )); ?>