Skip to content

Instantly share code, notes, and snippets.

@auniverseaway
Created January 15, 2014 21:54
Show Gist options
  • Save auniverseaway/8445523 to your computer and use it in GitHub Desktop.
Save auniverseaway/8445523 to your computer and use it in GitHub Desktop.
Get all images attached to a wordpress post except for the thumbnail image.
function slideshow_hero($postid) {
$thumb_ID = get_post_thumbnail_id($postid);
$args = array(
'post_type' => 'attachment',
'numberposts' => -1,
'post_mime_type' => 'image',
'post_status' => null,
'exclude' => $thumb_ID,
'post_parent' => $postid);
$attachments = get_posts($args);
if ($attachments) {
foreach ($attachments as $attachment) {
// Do stuff with your iamges
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment