8.5.x node.module node_load($nid = NULL, $reset = FALSE)
8.0.x node.module node_load($nid = NULL, $reset = FALSE)
8.1.x node.module node_load($nid = NULL, $reset = FALSE)
8.2.x node.module node_load($nid = NULL, $reset = FALSE)
8.3.x node.module node_load($nid = NULL, $reset = FALSE)
8.4.x node.module node_load($nid = NULL, $reset = FALSE)
8.6.x node.module node_load($nid = NULL, $reset = FALSE)
4.6.x node.module node_load($conditions, $revision = NULL, $reset = NULL)
4.7.x node.module node_load($param = array(), $revision = NULL, $reset = NULL)
5.x node.module node_load($param = array(), $revision = NULL, $reset = NULL)
6.x node.module node_load($param = array(), $revision = NULL, $reset = NULL)
7.x node.module node_load($nid = NULL, $vid = NULL, $reset = FALSE)

Load a node object from the database.


$param: Either the nid of the node or an array of conditions to match against in the database query

$revision: Which numbered revision to load. Defaults to the current version.

$reset: Whether to reset the internal node_load cache.

Return value

A fully-populated node object.

27 calls to node_load()
blogapi_blogger_edit_post in modules/blogapi/blogapi.module
Blogging API callback. Modifies the specified blog node.
blogapi_blogger_get_post in modules/blogapi/blogapi.module
Blogging API callback. Returns a specified blog node.
blogapi_mt_get_post_categories in modules/blogapi/blogapi.module
Blogging API callback. Returns a list of the taxonomy terms that are assigned to a particular node.
blogapi_mt_publish_post in modules/blogapi/blogapi.module
Blogging API callback. Publishes the given node
blogapi_mt_set_post_categories in modules/blogapi/blogapi.module
Blogging API callback. Assigns taxonomy terms to a particular node.

... See full list


modules/node/node.module, line 709
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($param = array(), $revision = NULL, $reset = NULL) {
  static $nodes = array();
  if ($reset) {
    $nodes = array();
  $cachable = $revision == NULL;
  $arguments = array();
  if (is_numeric($param)) {
    if ($cachable) {

      // Is the node statically cached?
      if (isset($nodes[$param])) {
        return is_object($nodes[$param]) ? drupal_clone($nodes[$param]) : $nodes[$param];
    $cond = 'n.nid = %d';
    $arguments[] = $param;
  elseif (is_array($param)) {

    // Turn the conditions into a query.
    foreach ($param as $key => $value) {
      $cond[] = 'n.' . db_escape_table($key) . " = '%s'";
      $arguments[] = $value;
    $cond = implode(' AND ', $cond);
  else {
    return FALSE;

  // Retrieve a field list based on the site's schema.
  $fields = drupal_schema_fields_sql('node', 'n');
  $fields = array_merge($fields, drupal_schema_fields_sql('node_revisions', 'r'));
  $fields = array_merge($fields, array(

  // Remove fields not needed in the query: n.vid and r.nid are redundant,
  // n.title is unnecessary because the node title comes from the
  // node_revisions table.  We'll keep r.vid, r.title, and n.nid.
  $fields = array_diff($fields, array(
  $fields = implode(', ', $fields);

  // Rename timestamp field for clarity.
  $fields = str_replace('r.timestamp', 'r.timestamp AS revision_timestamp', $fields);

  // Change name of revision uid so it doesn't conflict with n.uid.
  $fields = str_replace('r.uid', 'r.uid AS revision_uid', $fields);

  // Retrieve the node.
  // No db_rewrite_sql is applied so as to get complete indexing for search.
  if ($revision) {
    array_unshift($arguments, $revision);
    $node = db_fetch_object(db_query('SELECT ' . $fields . ' FROM {node} n INNER JOIN {users} u ON u.uid = n.uid INNER JOIN {node_revisions} r ON r.nid = n.nid AND r.vid = %d WHERE ' . $cond, $arguments));
  else {
    $node = db_fetch_object(db_query('SELECT ' . $fields . ' FROM {node} n INNER JOIN {users} u ON u.uid = n.uid INNER JOIN {node_revisions} r ON r.vid = n.vid WHERE ' . $cond, $arguments));
  if ($node && $node->nid) {

    // Call the node specific callback (if any) and piggy-back the
    // results to the node or overwrite some values.
    if ($extra = node_invoke($node, 'load')) {
      foreach ($extra as $key => $value) {
        $node->{$key} = $value;
    if ($extra = node_invoke_nodeapi($node, 'load')) {
      foreach ($extra as $key => $value) {
        $node->{$key} = $value;
    if ($cachable) {
      $nodes[$node->nid] = is_object($node) ? drupal_clone($node) : $node;
  return $node;


joseonate’s picture

Note that this function returns a (bool) FALSE if the node is not found.

Dave Reid’s picture

If you are loading a *lot* of nodes with node_load(), make sure to use the $reset parameter so that every node isn't kept in the function's static cache (and increasing memory usage):

node_load($nid, NULL, TRUE);
Garrett Albright’s picture

Specifically, what that does is clear node_load()'s cache before adding the node to be loaded to it. That means that there will always be at least one loaded node in the cache if you load nodes this way. If you want to clear the cache for good, try:

node_load(FALSE, NULL, TRUE);

…which will return FALSE. (The first parameter could also be NULL, or anything else that isn't an array, number, or numeric string.)

flaviovs’s picture

Often modules load nodes using the following construct:

$node = node_load(array("nid" => $nid));

If I understand the function code correctly, this calling form will always do a database call, i.e. it will bypass caching.

Island Usurper’s picture

Yes, it will always do a database call, but it will still store the result in the static variable. If you want to make sure the cache doesn't get too big, you have to set $reset to TRUE at least some of the time.

lookatthosemoose’s picture

is beautiful... no icky node_load() calls. Thank you wils.solutions!

carvalhar’s picture

to load a node by a param of the node, as vid (revision):
$node = node_load(array('vid' => $myVID));

blacklabel_tom’s picture

To load a users profile using just their uid:

$profile = node_load(array(
  'uid' => $user->uid,
  'type' => 'user_profile',