Last active
September 26, 2016 11:37
-
-
Save fcgist/84591b3357a7af81212de78cdd82a96d to your computer and use it in GitHub Desktop.
Multiple Google Map Post markers on single page using ACF plugin
This file contains hidden or 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
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