Support

Account

Home Forums Add-ons Repeater Field Combine 2 repeater rows with same values Reply To: Combine 2 repeater rows with same values

  • Thank you, I managed to get that but they are still not merging alphabetically.
    Here is my code:
    `<!– ********************************** PIGEONS AND DOVES –>
    <?php if( ($pigeons_and_doves || $other_pigeons_and_doves) ): //<!– THIS WILL NOT HIDE when empty –>

    // Add all rows of $this_array to the array of all rows.
    if ( have_rows( ‘pigeons_and_doves’ ) ) :
    while ( have_rows( ‘pigeons_and_doves’ ) ) : the_row();
    $final_array[] = [
    ‘bird_name’ => get_sub_field( ‘pigeon_and_dove_species’ ) ,
    ‘price’ => get_sub_field( ‘bird_price’ ) ,
    ];
    endwhile;
    endif;

    // Add all rows of $that_array to the array of all rows.
    if ( have_rows( ‘other_pigeons_and_doves’ ) ) :
    while ( have_rows( ‘other_pigeons_and_doves’ ) ) : the_row();
    $final_array[] = [
    ‘bird_name’ => get_sub_field( ‘other_pigeon_and_dove_species’ ) ,
    ‘price’ => get_sub_field( ‘other_bird_price’ ) ,
    ];
    endwhile;
    endif;
    sort($final_array);
    ?>
    <div class=”animal-listing-col”>
    <table>
    <tr>
    <th>Pigeons and Doves</th>
    <th>PRICE</th>
    </tr>
    <?php foreach($final_array as $row) {
    ?>
    <tr>
    <td><?php echo $row[‘bird_name’]; ?> </td>
    <!– CURRENCY –> <td><?php if( get_field(‘currency’) && $row[‘price’] && is_numeric($row[‘bird_price’])): the_field(‘currency’); endif; ?>
    <?php echo $row[‘price’]; ?>
    </td>
    </tr>
    <?php } ?>
    </table>
    </div> <!– end pigeons loop –>
    <?php endif; ?>
    <!– ********************************** end pigeons and doves –>