2017-03-22 43 views
0

我有一個名爲sub_seminars的ACF中繼器字段。 在某些帖子中,轉發器有多行。 我想通過行循環,並單獨顯示每個職位根據該子場「起始日期」在wordpress中通過ACF中繼器行循環並分別顯示每行

我做這樣的事情

<?php 
          $count = 0; 
           $your_repeater = get_field('sub_seminars'); 
           if($your_repeater){ 
           while(have_rows('sub_seminars')): the_row(); 
           $count++; 
           $my_field = get_sub_field('start_date'); 
           if ($count == 1) { ?> 



           <?php while (have_posts()) : the_post(); ?> 

                 <?php 
          // populate config with current post settings 
          presscore_populate_post_config(); 

          presscore_get_template_part('theme', 'blog/list/blog-list-post'); 
          ?> 

           <?php endwhile; ?> 

         <?php } endwhile; } ?> 

但它工作在第一篇文章即計數== 1當你增加計數失敗

回答

0
<?php 
       $seminarid = get_the_ID(); 
       $sub_seminars = get_field('sub_seminars', $seminarid); 

       for ($nidu = 0; $nidu < count($sub_seminars); $nidu ++){ 

///////// Place your code here ///////////// 

} ?> 

這是什麼工作。

0

變化

if ($count == 1) { 

if ($count > 1) { 

它看起來像你只運行循環檢索字段,如果你在第一次迭代。

+0

它循環並返回很多結果。我試過這個。而不是返回2結果它返回數百 – Damon