We tried to get specific nodes using EntityFieldQuery.
Drupal 7 – Get specific nodes using EntityFieldQuery
It returns a list of node ids which fulfill the query conditions. The next step is usually the retrieval of the nodes by the node ids. This can be done by the following example using node_load_multiple().
$query = new EntityFieldQuery(); $query->entityCondition('entity_type', 'node') ->entityCondition('bundle', '<CONTENT TYPE>') // ex. article ->propertyCondition('uid', $uid) // node written by a specific user ->propertyCondition('status', 1) // published nodes ->propertyCondition('created', REQUEST_TIME - 3600, '>='); // created within the past 1 hour $result = $query->execute(); if (isset($result['node'])) { $nids = array_keys($result['node']); return node_load_multiple($nids); } else { return array(); }
Done =)
Reference: Drupal API – node_load_multiple
2 thoughts on “Drupal 7 – Get mulitple nodes using EntityFieldQuery and node_load_multiple()”