Advanced Custom Fields
Creating a gallery using ACF loop (1 post)

  1. stephaniebane
    Posted 3 years ago #

    I made a gallery combining ACF and Basic Slider. (http://basic-slider.com/) The admin can control the team members and then they spit out in the gallery. Everything is working fine - except if the loop ends with a grouping of four. I set it up so that if there are four people, it would create a new slide. It works great if there are more people, but if it ends on a four, it creates a blank slide. How can I tell the loop to NOT create a slide if the content doesn't exist? I know it's not an issue with the gallery plugin because I tested it without the ACF capabilities and just static text. The issue is the loop because it creates an extra container. Any ideas? Code below:

    <ul class="bjqs">
     $rows = get_field('team_member');
    $person = 1;
    echo '<li class="slide">';
    foreach($rows as $row)
    '<div class="ind-team-member">
    <div class="ind-team-member-img-holder"><img src='. $row['image'] . ' alt="'. $row['name'] . '" /></div>
    <div class="ind-team-content"><h4>'. $row['name'] . '</h4>' . $row['contact_information'] .'</div>
    if($person==4){ ?>
    <li class="slide">
    $person = 0;


Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Advanced Custom Fields
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic