1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
$columns = 4;
$contatore = 0;
// LOOP FOREACH through each image
  foreach ( $attachments as $id => $attachment ) {

$contatore++;
  // Attachment page ID
    $att_page = get_attachment_link($id);
    // Returns array
    $img = wp_get_attachment_image_src($id, 'large');
    $img = $img[0];
    $thumb = wp_get_attachment_image_src($id, 'medium');
    $thumb = $thumb[0];
    // Set the image titles
    $title = $attachment->post_title;
    // Set the image captions
    $description = $attachment->post_content;
    if($description == '') $description = $attachment->post_excerpt;

    // Build html for each image
//build columns...
if ( $contatore == 1 )
$output .= "\n\t\t<div class='left_column'>";
if ( $contatore == 3 )
$output .= "\n\t\t<div class='right_column'>";

    $output .= "\n\t\t<div>";
    $output .= "\n\t\t\t<a href='".$img."'>";
    $output .= "\n\t\t\t\t<img src='".$thumb."' alt='".$description."' title='".$description."' />";
    $output .= "\n\t\t</a>";
    $output .= "\n\t\t<strong>".$title."</strong>";
    $output .= "\n\t\t<span>".$description."</span>";
    $output .= "\n\t\t</div>";
$output .= $contatore;
if ( $contatore == 2 || $contatore == 4)
$output .= "\n\t\t</div>";

if ( $contatore == 4){
$output .= "\n\t\t<br style='clear: both' />";
$contatore=0;
}
  // END FOREACH
  }