Skip to content

Instantly share code, notes, and snippets.

@erickarbe
Created January 3, 2013 20:47
Show Gist options
  • Save erickarbe/4447113 to your computer and use it in GitHub Desktop.
Save erickarbe/4447113 to your computer and use it in GitHub Desktop.
Get all the images from a WordPress post
<?php $attachments = get_children( array('post_parent' => get_the_ID(), 'post_type' => 'attachment', 'post_mime_type' =>'image') );
foreach ( $attachments as $attachment_id => $attachment ) {
$url = wp_get_attachment_url($attachment->ID);
echo '<a href="' . $url . '" rel="prettyPhoto[' . $gallerynumber . ']">' . wp_get_attachment_image( $attachment_id, 'full_size' ) . '</a>';
} ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment