ACF 转发器字段显示在 <li></li> 之外
ACF repeater field showing outside of <li></li>
我创建了一个自定义小部件,我在其中调用了一些 ACF 项目。我已经回显了我所有的自定义字段并且它们工作正常但是出于某种原因当我查看源代码时我的转发器字段项目显示在 <li>
之外?知道我的代码哪里出错了吗?
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;
它输出这个
<p class="contact-title">Background/Experience</p>
<ul>
Babysitter
<li></li>
Driver's Permit
<li></li>
OG loc
<li></li>
</ul>
the_field()
函数 echo-es 内容。如果要将 <li>
与返回值连接起来,则必须使用 get_sub_field()
- 它只有 returns 值。所以
echo "<li>". get_sub_field('licences__permits__etc'). "</li>";
或
echo "<li>";
the_sub_field('licences__permits__etc');
echo "</li>"
我创建了一个自定义小部件,我在其中调用了一些 ACF 项目。我已经回显了我所有的自定义字段并且它们工作正常但是出于某种原因当我查看源代码时我的转发器字段项目显示在 <li>
之外?知道我的代码哪里出错了吗?
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;
它输出这个
<p class="contact-title">Background/Experience</p>
<ul>
Babysitter
<li></li>
Driver's Permit
<li></li>
OG loc
<li></li>
</ul>
the_field()
函数 echo-es 内容。如果要将 <li>
与返回值连接起来,则必须使用 get_sub_field()
- 它只有 returns 值。所以
echo "<li>". get_sub_field('licences__permits__etc'). "</li>";
或
echo "<li>";
the_sub_field('licences__permits__etc');
echo "</li>"