• Resolved Restless Web

    (@triharder)


    Hi there!

    I have a need to import many locations into the events plugin and am running into a little trouble.

    I am using the WP Ultimate CSV Importer which is great because I can use it to import Locations which are a custom post type!

    The only trouble is, I am unable to import the address which is obviously an important field to import. I was wondering if you could tell me what the correct field names are to use when I import? I tried location_address and location-address but that does not seem to work.

    Thanks for your help!

    http://wordpress.org/plugins/events-manager/

Viewing 11 replies - 1 through 11 (of 11 total)
  • Hi,

    There is a location_address column in the wp_em_locations database but there are also these to:

    location_town
    location_state
    location_postcode
    location_region
    location_country

    It might be you need to split the addresses you’re importing across these different fields.

    Thread Starter Restless Web

    (@triharder)

    Hey thanks for the response.

    I did actually split the address. I’ve even found a plugin that allows me to import a csv directly into the MySQL DB (http://www.tipsandtricks-hq.com/wp-csv-to-database-plugin-import-excel-file-content-into-wordpress-database-2116 very cool!)

    I imported all the necessary data into wp_em_locations but the addresses won’t pick up in the admin. Only when I add a location and manually enter the address does it pick it up…

    What am I missing here? My client has around 2000 locations that I need to import so this is critical.

    Thanks again for your help

    Can you check that the info is in the database correctly using something like phpMyAdmin?

    Thread Starter Restless Web

    (@triharder)

    Yeah, that is what I’ve been doing. I actually found that the plugin needs somewhat duplicate content for it to work. You can’t just populate the fields in wp_em_locations. You also need to add the address fields to the corresponding meta key in wp_postmeta – eg. _location_address, _location_state etc.

    Once I had populated the wp_postmeta table the locations started showing the addresses properly.

    Do you guys have any plans for an import add-on to the plugin? It would be a huge help for a lot of people I’m sure

    Hi,

    I don’t think you should handle the database manually. Instead you should try and use the API.

    If you create a custom post with WordPress API, Events Manager will create the item in wp_em_locations (as it is hooked to post save)

    Obviously, it is much slower at runtime than updating the database manually but it may be worth a try.

    Thread Starter Restless Web

    (@triharder)

    FranceImage, there’s no way I can do that 2000+ times. A database import is the only option for me

    I was not suggesting you did it by hand using the WP admin 🙂

    I meant using wp_insert_post() in a script instead of using SQL queries

    The plugin you mention (WP Ultimate CSV Importer) is updating the DB without calling WordPress API.

    So, you can search for another plugin which does the same job but using wp_insert_post() or write it yourself using WP Ultimate CSV Importer plugin as a starter file.

    Does is make sense ?

    Thread Starter Restless Web

    (@triharder)

    oooh, i see sorry about that!

    Hmm, ok interesting! I’ll look into that! Thanks for the tip

    There is a catch though,

    When you create location custom posts, Events Manager immediately creates post custom data. So when the importer sets the custom data, there are duplicated.

    The trick I was using was to remove the hook before inserting the post

    remove_action('save_post',array('EM_Location_Post_Admin','save_post'),1);

    And use Events Manager API to create the location

    $location = new EM_Location($post_id, 'post_id');
    $location->save();

    I tried with http://wordpress.org/plugins/wp-ultimate-csv-importer/ in function processDataInWP() in SmackImpCE.php

    For some reason, the hook to EM_Location_Post_Admin::save_post is always called

    If you manage to solve this pb you should be able to create your locations
    from a csv

    @RestlessWeb

    Do you plan to display google maps ?
    If yes, do you have the latitude/longitude of your locations ?

    I asked that because I was eventually able to import locations using csv

    However, events manager needs latitude and longitude; so my solution will be no good if you don’t have them

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Importing Many Locations’ is closed to new replies.