我创建了一个自定义小部件,我在其中调用了一些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>
答案 0 :(得分:0)
the_field()
函数回显内容。如果要将<li>
与返回值连接,则必须使用get_sub_field()
- 它只返回值。所以
echo "<li>". get_sub_field('licences__permits__etc'). "</li>";
或
echo "<li>";
the_sub_field('licences__permits__etc');
echo "</li>"