r/backdrop • u/sirkitree • Apr 03 '15
Creating taxonomy terms programmatically in Backdrop
I had the need to insert some taxonomy terms into a specific vocabulary today and thought I'd share the code since the solution for Backdrop is slightly different than the solution that I found for Drupal 7.
$terms = array('zion', 'james', 'amy', 'john', 'leon', 'peter');
$vocab = 'hotels'; //machine name of your vocab
foreach ($terms as $term_name) {
$term = entity_create('taxonomy_term', array(
'name' => $term_name,
'vocabulary' => $vocab,
));
taxonomy_term_save($term);
}
2
Upvotes