Support

Account

Home Forums Add-ons Repeater Field Repeater field with post object only outputting one row

Unread

Repeater field with post object only outputting one row

  • Hello,

    I am a complete newbie. The following code works except it only out puts the first row of the repeater field that has a post object. Any ideas?
    Thank you!

    <?php /* Template Name: ShowAllTracksTemplate */ ?>
    <?php
    $posts = get_posts(array(
    ‘posts_per_page’ => -1,
    ‘post_type’ => ‘track’
    ));
    if( $posts ): ?>

      <?php foreach( $posts as $post ):
      setup_postdata( $post );
      ?>

    • “><?php the_title(); ?>
      Alias: <?php the_field(‘alias’); ?>
      <br>
      <!–– DESCRIPTION REPEATER ––>
      <?php
      // check if the repeater field has rows of data
      if( have_rows(‘track description’) ):
      // loop through the rows of data
      while ( have_rows(‘track description’) ) : the_row();
      // display a sub field value
      echo ‘‘; the_sub_field(‘description_name’);echo ‘‘;
      echo ‘<br>’;
      // display a sub field value
      the_sub_field(‘description’);
      echo ‘<br>’;
      endwhile;
      else :
      // no rows found
      endif;
      ?>

      <!–– PITCHES REPEATER ––>
      <?php if( have_rows(‘add-clients’) ): ?>
      <?php while ( have_rows(‘add-clients’) ) : the_row(); ?>
      <?php $post_object = get_sub_field(‘client’); ?>
      <?php if( $post_object ): ?>
      <?php $post = $post_object; setup_postdata( $post ); ?>
      <table>
      <tr>
      <td>Client: <?php the_title(); ?></td>
      <td>Date Submitted:: <?php the_sub_field(‘date_submitted’); ?></td>
      <td>Status:: <?php the_sub_field(‘status’); ?></td>
      <td>Expiration Date:: <?php the_sub_field(‘contract_expiration_date’); ?></td>
      </tr>
      </table>
      <?php wp_reset_postdata(); ?>
      <?php endif; ?>

      <?php endwhile; ?>

      <?php endif; ?>

    • <?php endforeach; ?>

    <?php wp_reset_postdata(); ?>

    <?php endif; ?>

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.