Skip to content

Instantly share code, notes, and snippets.

@fcgist
fcgist / Function.php
Created September 28, 2016 11:28
Display Posts from Specific Categories on Google Maps using ACF
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' , 'category_name' => 'unites-states' ) );
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');
@fcgist
fcgist / Function.php
Last active September 26, 2016 11:37
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();
@fcgist
fcgist / function.php
Created September 12, 2016 12:38
Set the center location on Google map using ACF plugin
add_filter('wpgmp_maps_options','wpgmp_maps_options',1,2);
function wpgmp_maps_options($default,$map_id) {
global $post;
$acf_location = get_post_meta($post->ID,'location');
if(is_array($acf_location)) {
$default['center_lat']= $acf_location[0]['lat'];
$default['center_lng']= $acf_location[0]['lng'];
@fcgist
fcgist / gist:260b3269d2d088a640658f170b87e15a
Created September 8, 2016 04:55
Center a Google Map on the Current WordPress Post
add_filter('wpgmp_maps_options','wpgmp_maps_options',1,2);
function wpgmp_maps_options($default,$map_id) {
// Declare global $post to get current post data.
global $post;
// Get current post's latitude added by wp google map pro meta box.
$default[center_lat]= get_post_meta($post->ID,'_wpgmp_metabox_latitude');
// Get current post's longitude added by wp google map pro meta box.
$default[center_lng]=get_post_meta($post->ID,'_wpgmp_metabox_longitude');
//Return modified center location of the map.
return $default;