输出表中的转发器字段

时间:2017-07-21 11:30:13

标签: php wordpress advanced-custom-fields

我正在尝试在表格中输出acf 5 repeater field

我使用以下代码:

   <?php
            // check if the repeater field has rows of data
            if (have_rows('founder')):
?>
   <div class="control-group">
      <label class="control-label">Founders</label>
      <div class="controls">
         <table class="table table-hover">
   <thead>
            <tr>
               <th>Image</th>
               <th>Name</th>
            </tr>
   </thead>
   <tbody>
            <?php
                // loop through the rows of data
                while (have_rows('founder')):
                    the_row(); ?>
            <tr>
               <td> <img src="<?php the_sub_field('founder_img'); ?>"></img> </td>
               <td><?php echo get_sub_field('firstname'); ?> &nbsp; <?php the_sub_field('lastname'); ?></td>
            </tr>
            <?php
                endwhile; ?>
   </tbody>
         </table>
      </div>
   </div>
   <?php endif; ?>

然而,即使我在后端填写了所有字段,我也得到以下输出:

enter image description here

html输出如下所示:

<div class="control-group">
      <label class="control-label">Founders</label>
      <div class="controls">
         <table class="table table-hover">
   <thead>
            <tr>
               <th>Image</th>
               <th>Name</th>
            </tr>
   </thead>
   <tbody>
                        <tr>
               <td> <img src="https://example.com/wp-content/uploads/2016/03/no-avai.jpg"> </td>
               <td>test &nbsp; test</td>
            </tr>
                        <tr>
               <td> <img src="https://example.com/wp-content/uploads/2016/03/no-avai.jpg"> </td>
               <td>Firstname &nbsp; Lastname</td>
            </tr>
               </tbody>
         </table>
      </div>
   </div>

我有什么建议吗?

0 个答案:

没有答案