Skip to content

Instantly share code, notes, and snippets.

@codytooker
Created September 7, 2017 22:49
Show Gist options
  • Save codytooker/ef652549202b9df3bcea13a2333d75b2 to your computer and use it in GitHub Desktop.
Save codytooker/ef652549202b9df3bcea13a2333d75b2 to your computer and use it in GitHub Desktop.
US States to insert into a Wordpress Taxonomy
<?php
$states = array(
'Alabama',
'Alaska',
'Arizona',
'Arkansas',
'California',
'Colorado',
'Connecticut',
'Delaware',
'District of Columbia',
'Florida',
'Georgia',
'Hawaii',
'Idaho',
'Illinois',
'Indiana',
'Iowa',
'Kansas',
'Kentucky',
'Louisiana',
'Maine',
'Maryland',
'Massachusetts',
'Michigan',
'Minnesota',
'Mississippi',
'Missouri',
'Montana',
'Nebraska',
'Nevada',
'New Hampshire',
'New Jersey',
'New Mexico',
'New York',
'North Carolina',
'North Dakota',
'Ohio',
'Oklahoma',
'Oregon',
'Pennsylvania',
'Rhode Island',
'South Carolina',
'South Dakota',
'Tennessee',
'Texas',
'Utah',
'Vermont',
'Virginia',
'Washington',
'West Virginia',
'Wisconsin',
'Wyoming',
);
//The Taxonomy to insert the states into
$taxonomy = 'state';
//default args
$args = array();
foreach ($states as $state) {
wp_insert_term($state, $taxonomy, $args);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment