Reputation: 116
I'm migrating custom wordpress templates over from an old site to a new site. In the new site one of my older templates using ACF Repeater is generating unnecessary < p > breaks between each element in my echo. Here's the source code:
<?php
if( have_rows('features_list') ):
$i=0;
while ( have_rows('features_list') ) : the_row();
echo '<p><span class="purple">+ </span>' . get_sub_field('feature_item') . '</p>';
$i++;
endwhile;
endif;
?>
The rendered HTML comes out to:
<p>
<span class="purple">+ </span>
</p>
<p>Text Content Text Content</p>
What I need it to render as and what it was in my old template is:
<p><span class="purple">+ </span> Text Content Text Content</p>
Im suspecting that Wordpress is wrapping my get_sub_field() in a < p > and therefore is closing the < span > around a < p > because of the wpautop() function. Im running Wordpress 4.5.3 and seeing this.
Upvotes: 0
Views: 431
Reputation: 116
This has been resolved. The solution was in the Custom Fields dashboard within the specific subfield. There is an option for "New Lines" conditional formatting and by default it was set to "Automatically add paragraphs". I switched it to "none" and this fixed the problem.
Thanks
Upvotes: 1