5

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.

1 Answer 1

7

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; } 

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.