I have created a custom widget where I’m calling some ACF items in it. I have echoed out all my custom fields and they are working fine but for some reason my repeater field items are showing up outside of the <li>
when I look at the source code? Any idea where I went wrong in my code?
if( get_field('background') ):
echo "<p class='contact-title'>Background/Experience</p>";
echo "<ul>";
while( have_rows('background') ): the_row();
echo "<li>". the_sub_field('licences__permits__etc'). "</li>";
endwhile;
echo "</ul>";
endif;
it outputs this
<p class="contact-title">Background/Experience</p>
<ul>
Babysitter
<li></li>
Driver's Permit
<li></li>
OG loc
<li></li>
</ul>
the_field()
functions echo-es the content. If you want to concatenate<li>
with returned value, you must useget_sub_field()
– it only returns value. Soor