I have about 10,000 locations to import into a WordPress custom post type. I’d like to import them programatically some way, but I’m not sure how’s best to go about it.

There can be up to three levels in the hierarchy, however there are sometimes just two. Here’s an example of the table I have at the moment.

Country    | State           | Town/City
Australia  | New South Wales | Albury
Australia  | New South Wales | Armidale
Australia  | Queensland      | Ayr
Australia  | Queensland      | Bowen
China      |                 | Beijing
China      |                 | Changchun

I want to be careful to only import the country and state once. I also want to set each state to have the country as its parent and each town/city to have the state (if applicable) to be its parent, if there is no state, set the country as the parent.

Does anyone know the best way to import these as hierarchal posts in a custom post type?

Read more here: Import hierarchical posts (custom post type)


If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Related Wordpress search:

, , , , ,

Wordpress related questions and answers: