Just a quick question. I'm creating a node and adding a term to the node like this:

 $newNode->field_tags[$newNode->language][]['tid'] = "a digit here";

Fine, but how do I add more than one term per node? I've tried a comma-separated string of digits and an array of digits but neither work.


You can just keep adding to the array the way you're already doing:

$newNode->field_tags[$newNode->language][]['tid'] = "a digit here";
$newNode->field_tags[$newNode->language][]['tid'] = "another digit here";

Or you could loop instead:

$tids = array(1, 2, 3);
foreach ($tids as $tid) {
  $newNode->field_tags[$newNode->language][]['tid'] = $tid;
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.