
<?php if (have_rows('top_ad_group', 'option')):

      while (have_rows('top_ad_group', 'option')): the_row();

            $image = get_sub_field('top_ad_image');
            $link = get_sub_field('top_ad_link');

            if ($image) : ?>

  <section class="top-ad">
    <div class="container">
      <div class="row">

        <div class="col-12">

          <?php if ($link) : ?>

            <a class="w-100" href="<?php echo $link['url']; ?>" target="<?php echo $link['target']; ?>">

              <?php endif;?>

                <img class="img-fluid w-100" src="<?php echo esc_url($image['url']); ?>" alt="<?php echo esc_attr( $image['alt']); ?>" />

                <?php if ($link) : ?>

            </a>

            <?php endif;?>

        </div>
      </div>
    </div>
  </section>

  <?php endif;?>

    <?php endwhile; ?>
      <?php endif; ?>
