Created
March 28, 2013 19:59
-
-
Save raphaelchaib/5266317 to your computer and use it in GitHub Desktop.
WordPress: Show post's attachment images
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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