wordpress,google-maps,google-maps-api-3,acf , ACF Multiple Map Markers

ACF Multiple Map Markers


Tag: wordpress,google-maps,google-maps-api-3,acf

I'm using Advanced Custom Fields and want to pull in the field called 'location' to display some locations on a map. How would i adjust the following code to display multiple markers from my location field?

The format of the custom field is like so:

echo 'Location: ' . get_field('location');

outputs ...

Location: -33.890542,151.274856

Thanks for your help.

<div id="group-map" style="width: 100%; height: 300px;display:none;   float:left;margin:0 0 30px 0;"></div>
                   <script type="text/javascript">
var locations = [
  ['Bondi Beach', -33.890542, 151.274856, 4],
  ['Coogee Beach', -33.923036, 151.259052, 5],
  ['Cronulla Beach', -34.028249, 151.157507, 3],
  ['Manly Beach', -33.80010128657071, 151.28747820854187, 2],
  ['Maroubra Beach', -33.950198, 151.259302, 1]

var map = new google.maps.Map(document.getElementById('group-map'), {
  zoom: 10,
  center: new google.maps.LatLng(-33.92, 151.25),
  mapTypeId: google.maps.MapTypeId.ROADMAP

var infowindow = new google.maps.InfoWindow();

var marker, i;

for (i = 0; i < locations.length; i++) {  
  marker = new google.maps.Marker({
    position: new google.maps.LatLng(locations[i][1], locations[i][2]),
    map: map

  google.maps.event.addListener(marker, 'click', (function(marker, i) {
    return function() {
      infowindow.open(map, marker);
  })(marker, i));


You can create a custom query and loop through all locations.

var locations = [
        $args = array(
            'post_type' => 'your_post_type',
            'posts_per_page' => -1
        $locations = new WP_Query($args);
            while($locations->have_posts()){ the_post();
            $loc = get_field('location')
     ['<?php echo get_the_title(); ?>', <?php echo $loc[0]; ?>, <?php echo $loc[1]; ?>],
    <?php } } ?>


wp_schedule_event hook sheduled but not working

I'm trying to trigger cron job from WordPress Plugin that I'm writing (It's gonna take all new Products and export them to CSV every day) so the problem is that when I'm put this code in functions.php all working great and the code is valid but from the plugin folder...

How to fetch the page id and use it for an image name

I am new in php. I want to make a condition for showing page id and set my image name is pageId and show this background image in my header banner. How to fetch page id use it fetching image for my banner background img. Here is my code: <div...

how to use geocoder class to retrieve latitude and longitude through ajax

the json array which contains the list of addresses [ { "id": 0, "title": "Coop.Sociale Prassi e Ricerca Onlus", "latitude": 0, "longitude": 0, "address": "Viale Eleonora D'Arborea 12, Roma, IT" }, { "id": 0, "title": "San Lorenzo", "latitude": 0, "longitude": 0, "address": "Viale della Primavera 330, Roma, IT" },...

Bxslider, Custom Fields & Wordpress

Good Afternoon, can anyone explain how i can achieve two things with the existing code below: Remove the null values, as these are exporting bxslider items that have broken links For some reason two versions of each image in the the pager are showing. Can anyone see why and how...

Wordpress function to effect only one (custom) post type, and not every post

I'm having an issue with a custom post type (WP Job Manager). I am using the following code in my functions file to 'add a default image to posts that have no image attached'. function custom_default_cover_image( $image, $args ) { global $post; if ( $image ) { return $image; }...

Add second single product page in Woocommerce

Is it possible to add a second single product page in Woocommerce? So basically when I am at the single product page I click the "next" button and I get directed to the same single product page with another template. So I just want to retrieve the same data on...

How to crop image from center using wp_image_editor

I am working on WordPress plugin. In plugin the user upload images from meta field and in back end i use wp_image_editor for cropping and re sizing the images. The images re sized very well but on cropping the images not cropped very well. I give x-dimension 100 and y-dimension...

Wordpress Custom Post Type categroies

I have a custom post type called STORIES. When a user adds a new STORY, I need them to be able to assign a category (or multiple categories) to the post so I can sort them later by category. To do this, I only want specific categories I assign to...

BeautifulSoup: Parsing bad Wordpress HTML

So I need to scrape some a site using Python but the problem is that the markup is random, unstructured, and proving hard to work with. For example <p style='font-size: 24px;'> <strong>Title A</strong> </p> <p> <strong> First Subtitle of Title A </strong> "Text for first subtitle" </p> Then it will...

Changing font-size of
  • on wordpress

  • css,wordpress,html-lists
    I am adding some pages on a wordpress themed website. There is a table with 3 columns: 1st column will be the title (larger font). Since it looks better and editing is easier, I started using <ul> instead of <td> Even though it works fine on JSFIDDLE font-size on the...

    R stops displaying maps

    Few days ago I was familiarizing myself with displaying maps, plotting points on the map from http://rpubs.com/nickbearman/r-google-map-making Today, I have intermittent success in displaying maps. library(ggmap) map <- qmap('Anaheim', zoom = 10, maptype = 'roadmap') Outputs Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=Anaheim&zoom=10&size=640x640&scale=2&maptype=roadmap&language=en-EN&sensor=false And when I go to the URL...

    Coding after Wordpress loop not showing

    I have been working on a custom archive page but I have run into some trouble. The pagination is shifting down into the footer area. I have gone through my code several times and I cannot work out why this is happening. If I remove the loop, the template works...

    How To check Product Have Variation in woocommerce

    Is there any way to check the product has variation something like Please help me. <?php If (product has variation) { echo"This Product have Variations "; } else { echo "This Product does not have Variations "; } ?> ...

    How to exclude posts without featured images from custom post type WP_Query

    We have the following WP_Query which collects all custom posts (except id=191) and lists them randomly: $args_projekte = array( 'post_type' => 'projekt', 'posts_per_page' => 18, 'post__not_in' => array(191), 'orderby' => 'rand', ); $query_projekte = new WP_Query($args_projekte); How do we extend this to ALSO exclude all posts WITHOUT featured images? Thanks...

    Load Google Maps in a tab when tab is picked, and not from begining

    I have a TabLayout with 2 tabs. First tab ( Main tab ) is a list of store in a listview Second tab is the same list in a Google Maps. I noticed that When I go by default in the first tab ( list ), the GPS icon appears...

    WordPress expanding grid with thumbnail

    I'm using codrops solution to display team members in an expanding grid: http://tympanus.net/codrops/2013/03/19/thumbnail-grid-with-expanding-preview/ I was already able to change some code to display my post thumbnail in the grid preview. However, I want to display the same picture in full size in the expanded view. In the original version it...

    Excluding certain pages from being redirected to https

    I'm using the following rules on my WordPress website to: Redirect all http pages to https Redirect the careers page to http <IfModule mod_rewrite.c> RewriteEngine On # Go to https if not on careers RewriteCond %{SERVER_PORT} 80 RewriteCond %{REQUEST_URI} !^/careers$ [NC] RewriteRule ^(.*)$ https://www.mywebsite.com/$1 [R,L] # Go to http if...

    Text-decoration/CSS causing text to move

    I've tried a bunch of techniques to solve this. I've used float (left/right) and played with positioning (absolute & relative). None worked. Basically my navigation keeps moving when the the text decoration (font-weight: bold; in this case) is applied. I'm new to CSS and this is my first header- so...

    Wordpress page can't continue due to this error

    I just faced this problem recently, I don't what causes it . But I need help fixing it. The error are : http://www.udesign.my/aaf4/wp-admin/admin-ajax.php?action=woocommerce_checkout Failed to load resource: the server responded with a status of 500 (Internal Server Error) http://fonts.googleapis.com/css?family=century+gothic+:300,400 Failed to load resource: the server responded with a status of...

    Using variables for longitude and latitude with google maps api

    I've just started using the google maps API for browsers but I can't seem to get it to work when I place variables in the longitude/latitude places instead of numbers directly. I need the maps to populate from the value of two input elements. It doesn't work with variables but...

    WooCommerce seems to only orderby date and not price

    I am loading in variable products via a custom WP_Query $args = array( 'post_type' => 'product', 'posts_per_page' => 100, 'product_cat' => 'beast-balls', 'orderby' => 'date', 'order' => 'desc' ); $loop = new WP_Query( $args ); if ( $loop->have_posts() ) { while ( $loop->have_posts() ) : $loop->the_post(); ?> <div class="product-node cat-beast-balls">...

    ANDROID PLACE_PICKER (builder.build(context)

    Basically I am trying to implement a PLACE_PICKER for Android and I am getting this confusing error here: int PLACE_PICKER_REQUEST = 1; PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder(); Context context = getApplicationContext(); startActivityForResult(builder.build(context), PLACE_PICKER_REQUEST); The error is coming in line 4:" (builder.build(context), " and I have no idea why, I am...

    Uncaught error: Invalid type for google table column

    I recently started using google visualization due to its simplicity. But while implementing in my recent project i seem to have run into a bit of trouble. The program shown is used to pull data from a JSON object and utilize it to display data in the google tables. Now...

    ACF Multiple Map Markers

    I'm using Advanced Custom Fields and want to pull in the field called 'location' to display some locations on a map. How would i adjust the following code to display multiple markers from my location field? The format of the custom field is like so: echo 'Location: ' . get_field('location');...

    Can not link the author

    I am Making a blog site. I want to show all posts of a user by linking with his/her user name. But it's not working. My code is by <a href="<?php get_author_posts_url(get_the_author_meta('ID'));?>"><?php the_author();?></a> What's wrong with it actually?...

    need wordpress plugin to show 3 type of different kind of text, image and 2 buttons

    I have slider image on http://techturners.com/arman-badwal/ page in "featured work" section. I need plugin to create dynamic slider like image in section.I use many sliders like cyclone-slider but they show only title, description and image.

    How to plot data points at particular location in a map in R

    I have a dataset that looks like this: LOCALITY numbers 1 Airoli 72 2 Andheri East 286 3 Andheri west 208 4 Arya Nagar 5 5 Asalfa 7 6 Bandra East 36 7 Bandra West 72 I want to plot bubbles (bigger the number bigger would be the bubble) inside...

    CSS disable horizontaly scrolling - Wordpress [on hold]

    Hi im working on a wordpress blog and have the following problem: http://www.catlovers.co/17-cat-reactions-that-sum-up-your-love-life/ If i resize the browser (X-Axies) to a minimum like surfing on a mobile device i am able to scroll to the right in the Contend section (hold down middle mouse button). How can i change my...

    Run AJAX function on form submit button after javascript confirm() cancel

    I have a form where and AJAX function runs on form submission to make sure that the data in the form doesn't conflict with data in the database. If a conflict is found, the AJAX function pops up a confirm() box. If the user clicks "OK", the form is submitted....

    Accessing Coordinates in Nested JSON File

    I'm trying to access lat/lng of polygons within a nested JSON file and trying to draw them using new google.maps.Polygon(), but having some troubles. UPDATE-2: I am able to draw polygons, but it only draws the first polygon, not all 3: http://jsfiddle.net/vprbqaLm/10/ UPDATE: Check out my latest JSFiddle here: http://jsfiddle.net/vprbqaLm/9/...

    CSS mystery: why the extra height in my div's?

    I'm just starting in on a new site and am getting extra space at the top of the div's I'm building for the home page. Using Safari's Web Inspector, I've eliminated any obvious padding or margins being responsible; but it's also seemingly telling me that the height of the div's...

    Create a unique URL for linking to data pulled from a database [closed]

    Is it possible to create a unique URL to link to information that is called and displayed from a database? [I am struggling to articulate this question, so any suggestions for revising it are welcome.] Specifics: I have a page that includes an embedded map and related information about each...

    Google map infowindow position on custom marker

    I'm not using the Markers in Google Maps because I wish to render custom text and images on my marker, so what I did is a custom marker using Overlays. The Overlay position is not exactly like the marker so I played a bit with it and now it is...

    Android Studio: cannot upgrade google play services

    I have tried download the latest version on the sdk manager, but is still not working. I have seen other posts telling users to enter the following... compile 'com.google.android.gms:play-services:4.2.+' I do not understand where to enter it. I tried in the terminal feature of the android studio but it gives...

    login with username or email in wordpress

    I am working on login template...but I want to make login with username as well as email.I got code with for that but it is not worked,it is as follow: function login_with_email_address($username) { $user = get_user_by('email',$username); if(!empty($user->user_login)) $username = $user->user_login; return $username; } add_action('wp_authenticate','login_with_email_address',10,1); I already put action in 'authenticate'...

    Wordpress End If Statements

    Apologies, PHP is not my strongest area so this might seem super easy to others. I am trying to implement a statement to say, when there is something in my WooCommerce Cart to show the cart. If there's nothing in the cart then show nothing. The code I have so...

    Creating complex queries with WP_Query in Wordpress

    Here's a complex query which we've built using WP_Query. It should: Ignore post id 191 AND Select all posts with 'reihenfolge' <= 18 AND Ignore posts without a featured image AND Order them randomly Here is the code: $args_projekte = array( 'post_type' => 'projekt', 'posts_per_page' => 18, 'meta_query' => array('relation'...

    WooCommerce: How to display Category Name in single-product.php

    How can I display the category name in single-product.php? In archive-product.php the code is: <?php woocommerce_page_title(); ?> but what could I use to show the category name in the single-product.php that belong to the category?...

    Google map infowindow position

    Here is a sample google map with three polygons. I am setting the infowindow for each polygon as, for (var i in coordinates) { arr = []; for (var j=0; j < coordinates[i].length; j++) { arr.push( new google.maps.LatLng( parseFloat(coordinates[i][j][0]), parseFloat(coordinates[i][j][1]) )); bounds.extend(arr[arr.length-1]) } // Construct the polygon. polygons.push(new google.maps.Polygon({ paths:...

    woocommerce - make order notes required

    is it posible to make woo 'order_comments' field required - and show message If the field is not filled I have tried the following code but I can not get it to work. add_action('woocommerce_checkout_process', 'my_custom_checkout_field_process'); function my_custom_checkout_field_process() { // Check if set, if its not set add an error. if...

    mapFragment.getMapAsync(this) - NullPointerException

    I am using com.google.android.gms:play-services-maps:7.5.0 version of Google Maps services. When trying to call the below I get java.lang.NullPointerException: Attempt to invoke virtual method 'void com.google.android.gms.maps.SupportMapFragment.getMapAsync(com.google.android.gms.maps.OnMapReadyCallback)' on a null object reference. @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { SupportMapFragment mapFragment = (SupportMapFragment) getActivity().getSupportFragmentManager()...

    How to call posts from PHP

    I have a website, that uses WP Super Cache plugin. I need to recycle cache once a day and then I need to call 5 posts (URL adresses) so WP Super Cache put these posts into cache again (caching is quite time consuming so I'd like to have it precached...

    Foundation and Wordpress blank spaces

    Anyone has an idea about the blank spaces that I'm getting in a while loop with wordpress using foundation framework? <div class="large-8 columns"> <?php query_posts(array('category_name' => 'revista', 'paged' => get_query_var('paged'), 'posts_per_page' => 9 )); ?> <?php while ( have_posts() ) : the_post(); ?> <article class="boletin large-4 columns" style="min-height:1px;"> <a href="<?php...

    Woocommece login URL

    I have a custom page for login in Wordpress with Woocommerce integrated, and need that when a user click on my-account page, instead of using the login form from woocommerce, redirect to my custom login url. my-account page only must be seen in case the user is logged in,else, I...

    Retrive geolocation in real time (HTML5)

    I have this code: var map; var geocoder; function initialize() { var mapOptions = { zoom: 18 }; map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions); // Try HTML5 geolocation if(navigator.geolocation) { navigator.geolocation.getCurrentPosition(function(position) { var pos = new google.maps.LatLng(position.coords.latitude, position.coords.longitude); var marker = new google.maps.Marker({ position: pos, map: map, title: 'Posizione Attuale' });...

    Two language site in wordpress what i can do [on hold]

    I want to create 2 language site in word press. I am pretty new in word press. so what can i do. I will have 2 different theme for each language or do something else. The English is for left to right while Arabic is for right to left. So...

    Wordpress log out using URL and redirect to specify page

    I have one Wordpress installation . i need to log out the user without any indication user is coming from particular URL.Is it possible? My code: <?php if($_GET['logout'] == 1) { $redirect_to = current_page_url(); ?> <script> window.location.href="<?php echo wp_logout_url( $redirect_to ); ?>"; </script> <?php } ?> I am using above...

    GeoGoogle - Google Geocoder Java API

    Is still valid this project or it is deprecated ? I got a 404 Error checking the examples http://code.google.com/apis/maps/documentation/index.html#Geocoding_Examples

    how can i plot a route map?

    I am writing a simple application to plot multiple marker in the google map and connect it thought a path as it looks like a route . I can plot multiple marker . and search some article which plot the route map . but i can not plot it ....