wordpress - Extra p elements created when calling the_field() or get_content() from within p tags -


"philosophy_text" textarea field created acf plugin (advanced custom fields). when displaying field using the_field() within p tags, resulting markup messed 2 p elements created out of blue. unfortunately not happen particular plugin. encountered annoying problem default wordpress function the_content() many times in past:

my code:

<p class="philosophy__story">     <?php if (get_field('philosophy_text')) the_field('philosophy_text'); ?> </p> 

the resulting markup:

<p class="philosophy__story"></p> <p>far far away, behind word mountains, far countries vokalia , consonantia, there live blind texts. more text make sense have, short not though.</p> <p></p> 

is wordpress bug? workaround?

advanced custom fields' textarea field has setting how treat rendering new lines. default, setting set wrap content in <p> tags.

you can change either print out <br> tags newlines, don't newlines, or can remove wrapping <p> element in php code, , allow acf you.

acf setting


Comments