douyan2970 2016-01-27 15:11
浏览 51
已采纳

ACF中继器字段显示在<li> </ li>之外

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>
  • 写回答

1条回答 默认 最新

  • doudao1922 2016-01-27 18:35
    关注

    the_field() functions echo-es the content. If you want to concatenate <li> with returned value, you must use get_sub_field() - it only returns value. So

    echo "<li>". get_sub_field('licences__permits__etc'). "</li>";
    

    or

    echo "<li>";
    the_sub_field('licences__permits__etc');
    echo "</li>"
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?