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 多电路系统共用电源的串扰问题
  • ¥15 shape_predictor_68_face_landmarks.dat
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料