javascript – Advanced Custom Fields Repeater Not displaying second image on second Upload-ThrowExceptions

Exception or error:

I am creating a custom theme in WP using ACF. I am using a repeater to post images. The repeater code just works fine for the first image I post but for some reason when I upload the second image, it does not display on the front page.

                                <?php if( have_rows('latest1') ): ?>

                                    <div class="row">

                                    <?php while( have_rows('latest1') ): the_row(); 

                                        $image = get_sub_field('image');
                                        $title = get_sub_field('title');
                                        $news = get_sub_field('news');
                                        $more = get_sub_field('more');
                                        $date = get_sub_field('date');
                                    ?>

                                    <!-- REPEATING SEGMENT -->

                                  <div class="col-md-2">
                                      <a href="wrk-AboutUS.html" class="img-news-container">
                                          <img src="<?php echo $image["url"];?>" class="img-responsive" alt="Image">
                                      </a>
                                  </div>

                                  <div id="primary3" class="content-area col-md-7 no-padding-right">
                                      <main id="main3" class="site-main " >
                                          <article class="item-lastest-news itemBlogList">



                                              <div class="">
                                                  <a href="wrk-AboutUS.html"><h4 class="title-news"><?php echo $title; ?></h4></a>
                                                  <div class="">

                                                      <span class="dates" style="color:green;"><?php echo $date; ?></span>
                                                  </div>
                                                  <p> <?php echo $news; ?></p>

                                                  <a class="continueReading" href="<?php echo $link ?>"><span style="color: brown;">Continue Reading</span></a>
                                                  <hr>
                                              </div> <!-- End Text box -->
                                          </article><!-- End Arcicle -->
                                      </main>

                                  </div>
                                    <!-- REPEATING SEGMENT -->


                                    <?php endwhile; ?>

                                    </div> <!-- END ROW -->


                                    <?php endif; ?>

Whats could be the reason why on the second upload the image does not display on the front page?

How to solve:

Please try with below:

<?php wp_reset_query(); ?>
<?php if( have_rows('latest1') ): ?>
	<div class="row">
		<?php while( have_rows('latest1') ): the_row(); 
			$image = get_sub_field('image');
			$title = get_sub_field('title');
			$news = get_sub_field('news');
			$more = get_sub_field('more');
			$date = get_sub_field('date');
		?>
		<!-- REPEATING SEGMENT -->
		<div class="col-md-2">
			<a href="wrk-AboutUS.html" class="img-news-container">
				<img src="<?php echo $image["url"]; ?>" class="img-responsive" alt="Image">
			</a>
		</div>
		<div id="primary3" class="content-area col-md-7 no-padding-right">
			<main id="main3" class="site-main " >
				<article class="item-lastest-news itemBlogList">
					<div class="">
						<a href="wrk-AboutUS.html"><h4 class="title-news"><?php echo $title; ?></h4></a>
						<div class="">
							<span class="dates" style="color:green;"><?php echo $date; ?></span>
						</div>
						<p> <?php echo $news; ?></p>
						<a class="continueReading" href="<?php echo $link; ?>"><span style="color: brown;">Continue Reading</span></a>
					<hr>
					</div><!-- End Text box -->
				</article><!-- End Arcicle -->
			</main>
		</div>
		<!-- REPEATING SEGMENT -->
		<?php endwhile; ?>
	</div> <!-- END ROW -->
<?php endif; ?>

Leave a Reply

Your email address will not be published. Required fields are marked *