• Resolved Andy Macaulay-Brook

    (@andymacb)


    Hi, I need to import a CSV but I don’t think the add-on will support my requirements. I’m happy coding my own CSV importers for custom posts, with meta and taxonomy terms, but have some specific things to ask. I don’t have full control of the CSV file format that I need to import, which is why I don’t think that the add-on will work for me.

    This is for a dealer finder that I’m including on a site. The CSV will need re-uploading regularly for updates, but won’t have wp-store-locator IDs in it, so I’ll be matching for existing records on a postmeta field.

    Question 1: The CSV won’t have longitude & latitude data in it. There will be a few thousand records and it seems silly to look this data up every time the file is uploaded. Does wp-store-locator have a function I can call or an action to hook to populate longitude and latitude for a dealer?

    Question 2: if the answer to 1 is yes, do I need the address in a certain format? I’m being provided 5 address lines plus postcode but of course I can join any of these together that I need to.

    Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Tijmen Smit

    (@tijmensmit)

    Calling this function in your code, and passing the address details to it will get you the coordinates.

    It works best if it’s in this structure ‘address, zip, city, state, country’. At least include the address + city + country.

    Edit: calling the wpsl_call_geocode_api function won’t populate the fields, but it will get you the coordinates. The data where it has to go are wpsl_lat and wpsl_lng in the meta table.

    When you insert a new post with wp_insert_post, then it returns an ID, use that ID to insert the meta data.

    • This reply was modified 6 years, 12 months ago by Tijmen Smit.
    Thread Starter Andy Macaulay-Brook

    (@andymacb)

    That’s great, thanks!

    Thread Starter Andy Macaulay-Brook

    (@andymacb)

    Just to add that this worked perfectly.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Custom CSV import that I don’t think the add-on supports’ is closed to new replies.