Skip to content

Instantly share code, notes, and snippets.

@raphaelchaib
Created March 28, 2013 19:59
Show Gist options
  • Save raphaelchaib/5266317 to your computer and use it in GitHub Desktop.
Save raphaelchaib/5266317 to your computer and use it in GitHub Desktop.
WordPress: Show post's attachment images
<?php
// Show post's attachment images
function show_attachment_images() {
$attachments = get_posts( array(
'post_type' => 'attachment',
'posts_per_page' => -1,
'post_parent' => 42,
'exclude' => get_post_thumbnail_id()
) );
if ( $attachments ) {
echo '<div id="fullscreen-bg" class="group">';
foreach ( $attachments as $attachment ) {
$class = "post-attachment mime-" . sanitize_title( $attachment->post_mime_type );
$img = wp_get_attachment_image( $attachment->ID, 'full' );
echo $img;
}
echo '</div>';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment