Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
$query = new EntityFieldQuery();
$entities = $query->EntityCondition('entity_type', 'node')
->entityCondition('bundle', 'your_content_type_machine_name');
// We only care about terms 1 and 2
$terms = array(1, 2);
foreach ($terms as $term) {
$entities->fieldCondition('field_sections', 'tid', $terms);
}
$result = $query->execute();
$result = $entities->execute();
$nodes = array();
if (isset($result['node'])) {
$nids = array_keys($result['node']);
$nodes = node_load_multiple($nids);
}
$items = array();
foreach ($nodes as $node) {
$options = array('absolute' => TRUE);
$url = url('node/' . $node->nid, $options);
$items[] = l($node->title, $url, $options);
}
$theme_args = array('items' => $items, 'type' => 'ul');
$content = theme('item_list', $theme_args);
return $content;