Support

Account

Home Forums ACF PRO Customize Relationship 1 result Reply To: Customize Relationship 1 result

  • This can be solved by adding a counter. I have only included the loop and not all of your required code:

    
    <?php 
    
    function magazine_featured_articles() { 
      ?>
        <div class="fa_grid ">
          <div class="fa_wrapper wrap grid-4">
            <?php 
              $featured_posts = get_field('featured_posts_field', 'options');
              if ($featured_posts) {
                global $post;
                $count == 0;
                foreach ($featured_posts as $post) {
                  if ($count == 1) {
                    // first small image
                    // need to insert this
                    echo '<div class="fa-grid-scroll">';
                  }
                  ?>
                    <div class="fa_module <?php 
                        if ($count == 0) {
                          echo 'fa-big-thumb';
                        } else {
                          echo 'fa-small-thumb';
                        }
                      ?>">
                      <?php 
                        setup_postdata($post);
                        
                        // the rest of code for displaying each image here
                        
                      ?>
                    </div>
                  <?php 
                  $count++;
                } // end foeeach featured post
                wp_reset_postdata();
                // if the count of images > 1 then .fa-grid-scroll was inserted
                // need to close it 
                if ($count > 1) {
                  echo '</div>';
                }
              } // end if posts
            ?>
          </div>
        </div>
      <?php 
    }