I have a listing wordpress site and want to integrate geo data into the Wordpress MySQL Database for custom search functionality

I want to utilize different aspects to create different things...

City values will become taxonomies State values will become taxonomies Zip Code values will become taxonomies Latitude - will become custom fields Longitude - will become custom fields County will be come taxonomies

City Taxonomy -> City Taxonomy Terms State Taxonomy -> State Taxonomy Terms Zip Code Taxonomy -> Zip Code Taxonomy Terms Latitude -> Custom Field Value Longitude -> Custom Field Value County Taxonomy -> County Taxonomy Terms

Here are a couple sample entries from the SQL files I have:

DROP TABLE IF EXISTS `cities_extended`;
CREATE TABLE `cities_extended` (
`city` varchar(50) NOT NULL,
`state_code` char(2) NOT NULL,
`zip` int(5) unsigned zerofill NOT NULL,
`latitude` double NOT NULL,
`longitude` double NOT NULL,
`county` varchar(50) NOT NULL

INSERT INTO `cities_extended` VALUES ('Holtsville', 'NY', '00501', '40.8152',    '-73.0455', 'Suffolk');
INSERT INTO `cities_extended` VALUES ('Holtsville', 'NY', '00544', '40.8152', '-73.0455', 'Suffolk');
INSERT INTO `cities_extended` VALUES ('Adjuntas', 'PR', '00601', '18.1788', '-66.7516', 'Adjuntas');

Is this doable with Wordpress Database? Thanks

1 Answer 1


To answer your question... Yes, it's doable.

But to give you some pointers into the right direction...

I've known some folks who have had good success using the WordPress Importer plugin. You could conceivably export your geo data from your database (using whatever DB management tool you're comfortable with) to the import format that this plugin expects. Depending on your comfort level with PHP and DB schemas, you could even tweak this plugin to suit your needs.

But since you're probably looking for a "one time" import, you might even whip up a PHP script and leverage the wp_insert_term function. (Again, depending on your comfort with PHP). This is probably how I'd do it. In general, I'd create a DB connection to my geo database, loop all the records, and inside the loop use wp_insert_term (keeping track of which cities, states, zips I've already inserted if necessary so that I don't insert 20 "Holtsville" records).

So again... The answer is "Yes" definitely doable. But it might take a little work. Hope that helps a little. Good luck on the project!

  • Awesome, thanks Jared... I looked up some tutorials on custom sql importation and figured it out using your steps. Thanks again Commented Jul 8, 2011 at 14:01
  • Great, would you mind accepting the solution? Glad you got it working!
    – Jared Cobb
    Commented Jul 8, 2011 at 14:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.