Support

Account

Forum Replies Created

  • Okay, never mind. I figured it out. Here is my working code in case anyone has a similar problem.

    <?php 
                if( have_rows('episode_staff') ):
                while ( have_rows('episode_staff') ) : the_row(); 
                $user_id = get_sub_field('episode_staff_member')[ID];
                ?>
                <div class="masthead-single">
                  <h4 class="masthead-name"><?php echo get_sub_field('episode_staff_member')['user_firstname'] ?> <?php echo get_sub_field('episode_staff_member')['user_lastname'] ?></h4>
                  <ul>
                    <li><?php echo get_sub_field('episode_staff_member')['user_email'] ?></li>
                    <li><?php echo get_field('twitter_username', 'user_'. $user_id) ?></li>
                  </ul>    
                </div>          
                <?php endwhile;
              endif; ?>
  • Hi @acf_support — thanks for the reply.

    I changed my code to this, but still no luck:

    <?php 
                if( have_rows('episode_staff') ):
                while ( have_rows('episode_staff') ) : the_row(); 
                $user = get_sub_field('episode_staff_member');
                ?>
    
                <div class="masthead-single">
                  <?php foreach ($user as $user):
                  $user_id = $user->ID ?>
                  <h4 class="masthead-name"><?php echo get_user_meta($user, 'first_name', true) ?> <?php echo get_user_meta($user, 'last_name', true) ?></h4>    
                  <div class="masthead-title"><?php echo get_sub_field('twitter_username', 'user' . $user_id) ?>
                  </div>          
                  <?php endforeach; ?>
                </div>
                <?php endwhile;
              endif; ?>

    I believe it is a problem with the loop, as the foreach loop is cycling through 10 times and there are only 2 episode_staff rows…

Viewing 2 posts - 1 through 2 (of 2 total)