Last active
August 29, 2015 14:11
-
-
Save nikibrown/727b3add0a0e660706ec to your computer and use it in GitHub Desktop.
Combine Advanced Custom Fields Relationship field + google maps field
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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> | |
</div><!--/.marker--> | |
<?php endforeach; ?> | |
<?php wp_reset_postdata(); // IMPORTANT - reset the $post object so the rest of the page works correctly ?> | |
</div><!--/.acf-map--> | |
<?php endif; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment