This is a code snippet I use quite often to display custom galleries in my themes. Paste the following code within the loop of your page template.
1 | echo '<ul id="Thumbnails">'; |
3 | $args = array( 'post_type' => 'attachment', 'numberposts' => -1,'post_status' => null, 'post_parent' => $post->ID ); |
4 | $attachments = get_posts($args); |
6 | foreach ( $attachments as $attachment ) { |
8 | $image_attributes = wp_get_attachment_image_src( $attachment->ID ); |
9 | $imgTitle = $attachment->post_title; |
10 | $imgCaption = $attachment->post_excerpt; |
11 | $imgDescription = $attachment->post_content; |
13 | echo '<li><a href="' . $attachment->guid . '"><img '; |
15 | if ( $attachment->post_name == $_GET['image'] ) { echo 'class="active"'; } |
17 | echo ' src="' . $attachment->guid . '" title="' . $imgCaption . '" alt="' . $imgTitle . ' - ' . $imgDescription . '" /></a></li>' . "\n"; |
23 | echo '<div style="clear: both;"></div>'; |