Skip to content

Instantly share code, notes, and snippets.

@jongamble
Created February 8, 2013 16:01
Show Gist options
  • Save jongamble/4739934 to your computer and use it in GitHub Desktop.
Save jongamble/4739934 to your computer and use it in GitHub Desktop.
Wordpress insert terms function
<?php
$terms = array(
'Birmingham - AL',
'Dothan - AL',
'Huntsville - AL',
'Montgomery - AL',
'Mobile - AL',
'Anchorage - AK',
'Fairbanks - AK',
'Juneau - AK',
'Phoenix - AZ',
'Tuscon - AZ',
'Yum - AZ',
'Fayetteville - AR',
'Jonesboro - AR',
'Little Rock - AR',
'Fresno - CA',
'Los Angeles - CA',
'San Diego - CA',
'San Francisco - CA',
'Bakersfield - CA',
'Palm Springs - CA',
'Sacramento - CA',
'Colorado Springs - CO',
'Denver - CO',
'Grand Junction - CO',
'Hartford - CT',
'Washington - DC',
'Ft Myers - FL',
'Gainesville - FL',
'Orlando - FL',
'Panama City - FL',
'Tallahassee - FL',
'Tampa - FL',
'Miami - FL',
'West Palm Beach - FL',
'Jacksonville - FL',
'Albany - GA',
'Atlanta - GA',
'Augusta - GA',
'Columbus - GA',
'Macon - GA',
'Savannah - GA',
'Boise - ID',
'Twin Falls - ID',
'Springfield - IL',
'Chicago - IL',
'Bloomington - IL',
'Rockford - IL',
'Evansville - IN',
'Ft Wayne - IN',
'Lafayette - IN',
'Terre Haute - IN',
'Indianapolis - IN',
'South Bend - IN',
'Cedar Rapids - IA',
'Des Moines - IA',
'Sioux City - IA',
'Rochester - IA',
'Davenport - IA',
'Kansas City - KS',
'Wichita - KS',
'Topeka - KS',
'Bowling Green - KY',
'Lexington - KY',
'Louisville - KY',
'alexandria - LA',
'Lafayette - LA',
'Lake Charles - LA',
'New Orleans - LA',
'Shreveport - LA',
'Baton Rouge - LA',
'Portland - ME',
'Balitmore - MD',
'Salisbury - MD',
'Springfield - MA',
'Boston - MA',
'Alpena - MI',
'Detroit - MI',
'Flint - MI',
'Grand Rapids - MI',
'Lansing - MI',
'Marquette - MI',
'Traverse City - MI',
'Minneapolis - MN',
'St Paul - MN',
'Duluth - MN',
'Biloxi - MS',
'Greenwood - MS',
'Hattiesburg - MS',
'Jackson - MS',
'Meridian - MS',
'Tupelo - MS',
'Columbia - MO',
'Springfield - MO',
'St Joseph - MO',
'St Louis - MO',
'Joplin - MO',
'Billing - MT',
'Bozeman - MT',
'Great Falls - MT',
'Helena - MT',
'Lincoln - NE',
'Omaha - NE',
'Las Vegas - NV',
'Reno - NV',
'Albuquerque - NM',
'Albany - NY',
'Binghamton - NY',
'Buffalo - NY',
'Elmira - NY',
'New York - NY',
'Rochester - NY',
'Syracuse - NY',
'Utica - NY',
'Watertown - NY',
'Asheville - NC',
'Charlotte - NC',
'Greensboro - NC',
'Greenville - NC',
'Raleigh - NC',
'Wilmington - NC',
'Fargo - ND',
'Bismark - ND',
'Cincinnati - OH',
'Dayton - OH',
'Lima - OH',
'Toledo - OH',
'Youngstown - OH',
'Zanesville - OH',
'Cleveland - OH',
'Columbus - OH',
'Oklahoma City - OK',
'Tulsa - OK',
'Eugene - OR',
'Portland - OR',
'Erie - PA',
'Lancaster - PA',
'Altoona - PA',
'Philadelphia - PA',
'Pittsburgh - PA',
'Wilkes Barre - PA',
'Providence - RI',
'Charleston - SC',
'Columbia - SC',
'Myrtle Beach - SC',
'Greenville - SC',
'Sioux Falls - SD',
'Rapid City - SD',
'Chattanooga - TN',
'Knoxville - TN',
'Memphis - TN',
'Nashville - TN',
'Jackson - TN',
'Abilene - TX',
'Amarillo - TX',
'Austin - TX',
'Beaumont - TX',
'Corpus Christi - TX',
'Dallas - TX',
'El Paso - TX',
'Fort Worth - TX',
'Houston - TX',
'Laredo - TX',
'Lubbock - TX',
'Odessa - TX',
'San Angelo - TX',
'San Antonio - TX',
'Tyler - TX',
'Victoria - TX',
'Waco - TX',
'Sherman - TX',
'Wichita - TX',
'Salt Lake City - Ut',
'Burlington - VT',
'Charlottesville - VA',
'Norfolk - VA',
'Richmond - VA',
'Roanoke - VA',
'Harrisonburg - VA',
'Seattle - WA',
'Spokeane - WA',
'Beckley - WV',
'Charleston - WV',
'Clarksburg - WV',
'Parkersburgh - WV',
'Wheeling - WV',
'Green Bay - WI',
'La Crosse - WI',
'Madison - WI',
'Milwaukee - WI',
'Wausau - WI',
'Casper - WY',
'Cheyenne - WY'
);
$output = array();
foreach($terms as $foo){
$title = trim(str_replace(' - ', ', ', $foo));
$slug = trim(strtolower(str_replace(' - ', ' ', $foo)));
$slug = str_replace(' ', '-', $slug);
$output = wp_insert_term(
$title,
'locations',
array(
'description' => '',
'slug' => $slug,
'parent' => -1
)
);
echo '<pre>';
print_r($output);
echo '</pre>';
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment