Home Forums Front-end Issues Relationship field & google maps Reply To: Relationship field & google maps

  • found this from another post – Worked like a charm for me.

    <?php $posts = get_field('featured_space'); if( $posts ): ?>
      <div class="acf-map">
        <?php foreach( $posts as $post): // variable must be called $post (IMPORTANT) ?>
          <?php setup_postdata($post); ?>
            <?php $space_address = get_field('space_address', $post->ID); ?>
              <div class="marker" data-lat="<?php echo $space_address['lat']; ?>" data-lng="<?php echo $space_address['lng']; ?>">
                <h4><?php the_title();?></h4>
                <p><?php echo $space_address['address']; ?></p>
    	  <?php endforeach; ?>
        <?php wp_reset_postdata(); // IMPORTANT - reset the $post object so the rest of the page works correctly ?>
    <?php endif; ?>