How can I order by weight using node_lode_multiple and the weight module ?

   <div id="photos_inner">
           $type = "staff";
           $nodes = node_load_multiple(array(), array('type' => $type)); 
           foreach($nodes as $staff):
  • You need to give us more information in order to help you.
    – pbonnefoi
    Nov 5, 2014 at 9:40

2 Answers 2


No, results of node_load_multiple() are in the order in which the node IDs were passed to it in the first place. There are no other sorting options through that function.

The weight module doesn't appear to have an API for this, so you'll need to create a query that joins the node and weight_weights tables to get the nids in the right order, then pass them to node_load_multiple().

  • node_load_multiple() return an array of node objects indexed by nid. Dec 19, 2019 at 15:13

In addition to Clive's answer, you can do it this way:

$type = 'your_content_type';
$query = db_select('node', 'n');
$query->join('weight_weights', 'w', 'n.nid = w.entity_id');
$query->fields('n', array('nid'))
  ->condition('type', $type)
  ->orderBy('w.weight', 'ASC');
$nids = $query->execute()->fetchCol();
$nodes = node_load_multiple($nids);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.