Skip to content

Instantly share code, notes, and snippets.

@fcgist
Last active September 26, 2016 11:37
Show Gist options
  • Save fcgist/84591b3357a7af81212de78cdd82a96d to your computer and use it in GitHub Desktop.
Save fcgist/84591b3357a7af81212de78cdd82a96d to your computer and use it in GitHub Desktop.
Multiple Google Map Post markers on single page using ACF plugin
add_filter("wpgmp_markers","add_markers",1,2);
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');
if(is_array($get_google_map))
{
$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