Skip to content

Instantly share code, notes, and snippets.

Last active September 26, 2016 11:37
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Multiple Google Map Post markers on single page using ACF plugin
function add_markers($markers,$map_id)
global $post;
$new_markers = array();
$the_query_map = new WP_Query( array( 'meta_key' => 'location' ) );
if($the_query_map->have_posts()) :
while($the_query_map->have_posts()): $the_query_map->the_post();
$get_google_map = get_post_meta(get_the_id(),'location','true');
$temp_marker = array();
$temp_marker ['location']['lat'] = $get_google_map['lat'];
$temp_marker ['location']['lng'] = $get_google_map['lng'];
$temp_marker ['title'] = get_the_title(get_the_id());
$temp_marker ['id'] = get_the_id();
$temp_marker ['location']['icon'] ='http://localhost/googlemap/wp-content/plugins/wp-google-map-gold/assets/images/icons/pin_green.png';
$new_markers [] = $temp_marker;
endwhile; endif;
$markers = array_merge($markers, $new_markers);
return $markers;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment