Support

Account

Home Forums General Issues Importing data to ACF Google Maps field

Unread

Importing data to ACF Google Maps field

  • Hi, I’ve created a CPT called ‘projects’ which has a Google Maps field called ‘location’. This works fine for creating new ‘projects’ however I have a CSV file with records that I need to import. Each record has a post name, LAT and LNG value. I wrote a script to create a WordPress XML import file. The post meta looks like this;

    
    ...
    <wp:postmeta>
    	<wp:meta_key><![CDATA[location]]></wp:meta_key>
    	<wp:meta_value>
    <![CDATA[
    a:4:{
    s:7:"address";s:0:"";
    s:3:"lat";d:50.0000000;
    s:3:"lng";d:-1.0000000;
    s:4:"zoom";i:9;
    }
    ]]></wp:meta_value>
    </wp:postmeta>
    ...
    

    When I import the XML file the pin is properly located on the map in post edit screen… however when I click to ‘save’ the post, the field is cleared.

    I’ve tried to set all of the optional fields too in the database like…

    a:12:{
    s:7:"address";s:0:"";
    s:3:"lat";d:50.0000000;
    s:3:"lng";d:-1.0000000;
    s:4:"zoom";i:9;
    s:8:"place_id";s:0:"";
    s:11:"street_name";s:0:"";
    s:17:"street_name_short";s:0:"";
    s:4:"city";s:0:"";
    s:5:"state";s:0:"";
    s:9:"post_code";s:0:"";
    s:7:"country";s:0:"";
    s:13:"country_short";s:0:"";
    }

    I assumed that it was because the search input is empty so I’ve even tried to make the field ‘required’ so that if someone updates the post they must first use the Google map to choose the placemarker again, but this didn’t work.

    I can’t work this out 🙁

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.