Skip to content

Instantly share code, notes, and snippets.

@jonathanpglick
Forked from anonymous/gist_setup_taxonomy.php
Created September 19, 2012 18:06
Show Gist options
  • Save jonathanpglick/3751195 to your computer and use it in GitHub Desktop.
Save jonathanpglick/3751195 to your computer and use it in GitHub Desktop.
<?php
$market_vocab = taxonomy_vocabulary_machine_name_load('markets');
$terms = array(
'Housing' => array(
'Affordable',
'Apartments',
'Condos',
'Student',
'Senior',
),
);
foreach ($terms as $term_name => $term_children) {
$term = new stdClass;
$term->vid = $market_vocab->vid;
$term->name = $term_name;
$term->description = _get_term_lipsum();
$parent_tid = taxonomy_term_save($term);
foreach ($term_children as $term_child_name) {
$term = new stdClass;
$term->vid = $market_vocab->vid;
$term->name = $term_child_name;
$term->description = _get_term_lipsum();
$term->parent = $parent_tid;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment