“philosophy_text” is a textarea field created with the ACF plugin (Advanced Custom Fields). When displaying this field using the_field() from within p tags, the resulting markup is messed up with two extra p elements created out of the blue. Unfortunately this does not happen only with this particular plugin. I encountered this annoying problem with default WordPress function the_content() many times in the 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 the word mountains, far from the countries Vokalia and Consonantia, there live the blind texts. Some more text that make sense for us to have, short not to much though.</p>
<p></p>

Is it a WordPress bug? Any workaround?

Read more here: Extra p elements created when calling the_field() or get_content() from within p tags


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: