I use the following code to load entities by their IDs.

$themes = entity_load('theme',array(7,8,9));
$thid = array();
foreach ($themes as $theme) {
  $thid[] = $theme->id; 

Next, I should add those IDs to an entity reference field ($tests->field_theme).

How can I achieve this?

Your Answer

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

Browse other questions tagged or ask your own question.