Skip to content

Instantly share code, notes, and snippets.

@ashleycam3ron
Created September 6, 2012 20:11
Show Gist options
  • Save ashleycam3ron/3660036 to your computer and use it in GitHub Desktop.
Save ashleycam3ron/3660036 to your computer and use it in GitHub Desktop.
Wordpress :: get attachment image
<?php
$attachment_id = $page->ID;
$current = get_the_ID();
$attachment = get_post( $attachment_id );
$args = array(
'post_type' => 'attachment',
'post_parent' => $current,
'post_mime_type' => 'image',
'post_status' => null,
'numberposts' => -1,
);
$attachments = get_posts($args); ?>
<div id="photo-alt" style="width:225px;height:570px;overflow:hidden;">
<?php if ($attachments) {
foreach ($attachments as $attachment) {
//echo wp_get_attachment_link($attachment->ID, 'full', false, false); ?>
<?php echo wp_get_attachment_image($attachment->ID, 'medium', false, false); ?>
<?php echo wp_get_attachment_image($attachment->ID, 'thumbnail', false, false);
}?>
</div>
<?php } ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment