Support

Account

Home Forums Add-ons Repeater Field Repeater front-end

Solving

Repeater front-end

  • Hi. I’m a total newbie and not really a PHP expert so this is probably an easy fix.

    I’ve got a repeater set up which is outputting the data to the front-end fine but I need the data split into infinite rows and 5 columns. Here is my code, where do I wrap the code to split it up?

    <?php
    
    // check if the repeater field has rows of data
    if( have_rows('itinerary_day_details') ):
    
     	// loop through the rows of data
        while ( have_rows('itinerary_day_details') ) : the_row();
    
            // display a sub field value
                    the_sub_field('date');
    		the_sub_field('port');
    		the_sub_field('arrival_time');
    		the_sub_field('departure_date');
    		the_sub_field('activity');
        endwhile;
    
    else :
    
        // no rows found
    
    endif;
    
  • Hi Barrowr, if you update your code to

    
    <?php if( have_rows('itinerary_day_details') ):?>
    <table>
    <!-- Header row for all cols in table -->
    <tr>
    <th>Date</th>
    <th>Port</th>
    <th>Arrival Time</th>
    <th>Departure Date</th>
    <th>Activity</th>
    </tr>
    <?php while ( have_rows('itinerary_day_details') ) : the_row(); ?>
    <tr>
    <td><?= the_sub_field('date'); ?></td>
    <td><?= the_sub_field('port'); ?></td>
    <td><?= the_sub_field('arrival_time'); ?></td>
    <td><?= the_sub_field('departure_date'); ?></td>
    <td><?= the_sub_field('activity'); ?></td>
    </tr>
    <?php endwhile; ?>
    <?php else: ?>
    <!-- if no rows are found add markup below -->
    <?php endif;?>
    
Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Repeater front-end’ is closed to new replies.