Support

Account

Home Forums General Issues Can't output repeated fields? Reply To: Can't output repeated fields?

  • Sorry, I don’t know why I can’t wrap my head around this, I think I’ve just been stressed out or something. I’ve tried a few other variations myself with the foreach loop, and then now yours am I missing something here? What else should I check?
    Here’s my full code I’m testing with

    
    <?php
       // Featured products feilds
       $featuredProductTitle = get_field('featuredproducttitle');
       
       $featuredProductSlide = get_field('featured_products_repeater');
       
       $featuredBestSellerSlide = get_field('best_selling_products_repeater');
       
       var_dump($featuredProductSlide);
    ?>
    <br>
    <h2>Data</h2>
    <?php
       var_dump($featuredBestSellerSlide);
       ?>
    
    <!-- Slider Menu -->
    <div class="product_slider_title_section">
       <div class="slider_title">
          <h2><?php echo $featuredProductTitle ?></h2>
          <hr class="title_line">
       </div>
       <div class="product_slider_controls">
          <h3><a id="featured">Featured</a></h3>
          <h3><a id="best_selling">Best Seller</a></h3>
          <h3><a id="new_arrivals">New Arrivals</a></h3>
       </div>
    </div>
    
    <div id="featured">
       <div class="product_slider-1">
       <?php if(have_rows('featured_products_repeater')):?>
          <?php while( have_rows('featured_products_repeater')): the_row(); ?>
         <?php  $args = array(
             	'post_type' => 'product',
             	'posts_per_page' => 3,
             ); 
             $loop = new WP_Query( $args );
             
             if ( $loop->have_posts() ) {
             
             	while ( $loop->have_posts() ) : $loop->the_post();
             
             		wc_get_template_part( 'content', 'product' );
             
             	endwhile;
             
             } else {
             	echo __( 'No products found' );
             }
             
             ?>      
          <?php endwhile;?> 
       </div>
       <?php endif;?>
    </div>
    
    <div id="best_selling">
       <?php if (have_rows('best_selling_products_repeater')) { ?>
          <div class="product_slider-2">
          <?php 
             while (have_rows('best_selling_products_repeater')) {
                the_row();
                $posts = get_sub_field('best_selling_product');
                foreach ($posts as $post) {
                  setup_post_data($post);
                  wc_get_template_part('content', 'product');
                }
             }
             ?>
          </div>
       <?php wp_reset_postdata(); 
       } ?>
    </div>
    
    <div id="new_arrivals" class="product_slider-3">
       <div>TEST TEST</div>
       <div>TEST TEST</div>
    </div>
    

    Also, I can 100% confirm that those are the correct field names.