How can I render my output in a series of DIVs rather than an "item_list"? The following code works in the sense that it outputs my series of photos in an unordered list. My question is - What changes would I need to make in order to render my output in a series of DIVs with class IDs? I plan to hook this up to JQuery Masonry and I'd prefer to break away from the limitations of them being in a list.

The following code pulls in my data.

function photo_gallery_contents($display) {
  $max_num = variable_get('photo_gallery_max', 3);
  $query = db_select('node', 'n')
    -&gt;fields('n', array('nid'))
    -&gt;condition('status', 1) //Published.    
    -&gt;condition('type','portfolio') // Only want our photos aka Portfolio content type
    -&gt;orderBy('created', 'DESC'); //Most recent first.

  if ($display == 'block') {
    // Restrict the range if called with 'block' argument
    $query-&gt;range(0, $max_num);
  } 
  // Now proceeds to execute().
  // If called by peg, query proceeds directly to execute().

  // Fetch the results for the nid field into an array.
  $nids = $query-&gt;execute()-&gt;fetchCol(); 

  // Load the node objects and return.
  return node_load_multiple($nids);


}

The code that renders all (but would like it to create a series of DIVs) is the following one.

function _photo_gallery_page() {
  $result = photo_gallery_contents('page');

  // Array to contain items for the page to render.
  $items = array();

  //Iterate over the resultset and format as links.
  foreach ($result as $node) {
    // Build a render array based on the field's display settings.
    $image = field_view_field('node', $node, 'field_image',array('label' =&gt; 'hidden',   'settings' =&gt; array('image_style' =&gt; 'thumbnail')));

    // Render the array down to the image HTML.
    $image_html = drupal_render($image);

    $items[] = array(
      'data' =&gt; l($image_html, 'node/' . $node-&gt;nid, array('html' =&gt; TRUE)),
    );
  }

  if (empty($items)) {
    // No content in the last 2 weeks.
    $page_array['photo_gallery_arguments'] = array(
      //Title serves as page subtitle.
      '#title' =&gt; t('All photos from ever'),
      '#markup' =&gt; t('No photos available.'),
    );
    return $page_array;  
  } 
  else {
    $page_array['photo_gallery_arguments'] = array(
      '#title' =&gt; t('All photos from ever'),
      '#items' =&gt; $items,
      // Theme hook with suggestion.  
      '#theme' =&gt; 'item_list',
      '#type' =&gt; 'div',
    );

    return $page_array;
  }
}
As far I understood you want render the following code in multiple &lt;divs&gt;.

$page_array['photo_gallery_arguments'] = array(
  '#title' =&gt; t('All photos from ever'),
  '#items' =&gt; $items,
  // Theme hook with suggestion.  
  '#theme' =&gt; 'item_list',
  '#type' =&gt; 'div',
);


Replace it with the following code.

   foreach($items as $item_key =&gt; $item) {
     $page_array['photo_gallery_arguments'][$item_key] = array(
       '#type' =&gt; 'container',
       '#attributes' =&gt; array(
         'class' =&gt; array(
           'my-class-' . $item_key,
         ),
       ),
     );

     $page_array['photo_gallery_arguments'][$item_key]['content'] = array(
       '#type' =&gt; 'markup',
       '#markup' =&gt; $item,
     );
   }


Or use the following code.

   foreach($items as $item_key =&gt; $item){
     $page_array['photo_gallery_arguments'][$item_key] = array(
       '#type' =&gt; 'markup',
       '#markup' =&gt; '&lt;div class="my-class-"' . $item_key . '&gt;' . $item . '&lt;/div&gt;',
     );
   }


Alternatively, you can use the following code.

   foreach($items as $item_key =&gt; $item){
     $page_array['photo_gallery_arguments'][$item_key] = array(
       '#type' =&gt; 'item',
       '#markup' =&gt; $item,
     );
   }


You can find more information about rendering arrays, and Form API.