8.5.x node.module node_load_multiple(array $nids = NULL, $reset = FALSE)
8.0.x node.module node_load_multiple(array $nids = NULL, $reset = FALSE)
8.1.x node.module node_load_multiple(array $nids = NULL, $reset = FALSE)
8.2.x node.module node_load_multiple(array $nids = NULL, $reset = FALSE)
8.3.x node.module node_load_multiple(array $nids = NULL, $reset = FALSE)
8.4.x node.module node_load_multiple(array $nids = NULL, $reset = FALSE)
8.6.x node.module node_load_multiple(array $nids = NULL, $reset = FALSE)
7.x node.module node_load_multiple($nids = array(), $conditions = array(), $reset = FALSE)

Loads node entities from the database.

This function should be used whenever you need to load more than one node from the database. Nodes are loaded into memory and will not require database access if loaded again during the same page request.

@todo Remove $conditions in Drupal 8.


$nids: An array of node IDs.

$conditions: (deprecated) An associative array of conditions on the {node} table, where the keys are the database fields and the values are the values those fields must have. Instead, it is preferable to use EntityFieldQuery to retrieve a list of entity IDs loadable by this function.

$reset: Whether to reset the internal node_load cache.

Return value

An array of node objects indexed by nid.

See also



14 calls to node_load_multiple()
blog_page_last in modules/blog/blog.pages.inc
Menu callback; displays a Drupal page containing recent blog entries of all users.
blog_page_user in modules/blog/blog.pages.inc
Menu callback; displays a Drupal page containing recent blog entries of a given user.
DrupalWebTestCase::drupalGetNodeByTitle in modules/simpletest/drupal_web_test_case.php
Get a node from the database based on its title.
NodeLoadHooksTestCase::testHookNodeLoad in modules/node/node.test
Test that hook_node_load() is invoked correctly.
NodeLoadMultipleTestCase::testNodeMultipleLoad in modules/node/node.test
Create four nodes and ensure they're loaded correctly.

... See full list


modules/node/node.module, line 946
The core that allows content to be submitted to the site. Modules and scripts may programmatically submit nodes using the usual form API pattern.


function node_load_multiple($nids = array(), $conditions = array(), $reset = FALSE) {
  return entity_load('node', $nids, $conditions, $reset);


pillarsdotnet’s picture

The number of nodes that can be loaded into memory in a single query is limited by the PDO layer, the database driver, configuration details, and of course, available memory. Passing too large an argument array to this function can result in the cryptic error message General error: 1 too many SQL variables.

A documentation bug has been posted to note the limited argument length.

chadmandoo’s picture

This example below uses a content type called "Product Type" (machine name "product_type", which is found on the content->content types page in drupal 7) and will return all the nodes of the product type. These are return as an array of objects which you will access accordingly. My example I run a foreach which turns $products into an object and I print out the nid and title.

$type = "product_type"; 
$nodes = node_load_multiple(array(), array('type' => $type)); 
foreach($nodes as $products):
<?php print $products->nid; ?>
<?php print $products->title; ?>
<?php endforeach; ?>
frob’s picture

this is one of many reasons why we have removed php as our templating engine.

vishal.sirsodiya’s picture

This is very helpful code ..:)

VladSavitsky’s picture

frob meant that using PHP code in templates is a bad practice.

First part should be in template.php or in theme-functions custom module:

// Very simple example:
function THEME_preprocess_page(&$vars) {
  $nodes = node_load_multiple(NULL, array('type' => "product_type"));
  foreach ($nodes as $nid => $node) {
    $vars['escaped_node_list'] .= l(check_plain($node->title), 'node/' . $node->nid);

Second part should be in tempate (.tpl.php):
print $escaped_node_list;

kingandy’s picture

Using EntityFieldQuery to replace the deprecated $conditions argument, you'd instead do something like this:

// First use EFQ to find node IDs.
$type = 'product_type';
$query = new EntityFieldQuery;
$result = $query->entityCondition('entity_type', 'node')
  ->entityCondition('bundle', $type)
if (!empty($result['nodes'])) {
  $nids = array_keys($result['nodes']);
  // Now use node_load_multiple() to load the nodes belonging to those node IDs.
  $nodes = node_load_multiple($nids);
  // .... continue as before

... though tbh EntityFieldQuery is also gone in Drupal 8 (I believe replaced by \Drupal::entityQuery), so this code will need to be further revised.

Moranbzh’s picture

With $result['node'] instead of $result['nodes'] it works ! ;)

otcassetmgmt’s picture

I built a checkbox form my goal is to load the objects so the form displays each. I can load 1 node and everything works, but when I add multiple it doesn't generate each as I need

Alex_Shut’s picture

$nodes = node_load_multiple(array(), array('type' => 'to_do', 'status' => 1));
page several forms. After submitting - an entry in the database and should appear in the form of updated records. But this is not happening.I getting data only after dropping cache = (

Collins405’s picture

I came here with problems with Path Auto, and needed to enable the generate automatic aliases option.

I enabled the Devel module and went to /devel/php, then ran this...

$type = "basic_page";
$nodes = node_load_multiple(array(), array('type' => $type));
foreach($nodes as $node) {
$node->path['pathauto'] = TRUE;