Support

Account

Home Forums General Issues Using relationship field to display repeater from a custom post type Reply To: Using relationship field to display repeater from a custom post type

  • Thanks John, I ended up solving it, my working code ended up being:

    <?php $accommodation_relationship = get_field( 'accommodation_relationship' ); ?>
    <?php if ( $accommodation_relationship ): ?>
    <?php foreach ( $accommodation_relationship as $post ):  ?>
    <?php setup_postdata ( $post ); ?>
    
    <?php
    if( have_rows('acommodation_location_repeater') ):
    while ( have_rows('acommodation_location_repeater') ) : the_row();
    ?>
    
    <div class="col-md-3 accommodation">
    <h3><?php the_sub_field( 'accommodation_name' ); ?></h3>
    <p class="description"><?php the_sub_field( 'accommodation_description' ); ?></p>
    <p class="address"><?php the_sub_field( 'accommodation_address' ); ?></p><br />
    <a href="tel:<?php the_sub_field( 'accommodation_phone' ); ?>" class="contact-link"><?php the_sub_field( 'accommodation_phone' ); ?></a><br />
    <a href="mailto:<?php the_sub_field( 'accommodation_email' ); ?>" class="contact-link"><?php the_sub_field( 'accommodation_email' ); ?></a>
    <?php $accommodation_website = get_sub_field( 'accommodation_website' ); ?>
    <?php if ( $accommodation_website ) { ?>
    <br />
    <button class="accommodation-bttn"><a href="<?php echo $accommodation_website; ?>">Website <i class="fas fa-chevron-right"></i></a></button>
    <?php } ?>
    </div>
    
    <?php endwhile; else : endif; ?>
    
    <?php wp_reset_query(); ?>
    
    <?php endforeach; ?>
    <?php wp_reset_postdata(); ?>
    <?php endif; ?>

    Thanks!