WebTechKitchen; Your Web Technology Kitchen, contact us to create, or maintain your websites and other digital properties.

programmatically save a taxonomy term

Submitted by barnettech on Sun, 02/17/2019 - 15:34
$node = Node::create(array(
    'type' => 'article',
    'title' => 'My Title',
    'langcode' => 'en',
    'uid' => '1',
    'status' => 1,
    'created' => $data[$dateIndex],
    'field_autor' => $data[$autorIndex],
    'field_teaser_text' => $data[$shortIndex],
    'field_mytaxonomy'  => [
      ['target_id' => 12345]
    ]
));
$node->save();