Created
March 26, 2012 14:00
-
-
Save miklb/2205266 to your computer and use it in GitHub Desktop.
grab all image attachments minus post_thumbnail in WordPress
This file contains hidden or 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
function kkf_get_images($overrides = '', $exclude_thumbnail = false) | |
{ | |
return get_posts(wp_parse_args($overrides, array( | |
'numberposts' => -1, | |
'post_parent' => get_the_ID(), | |
'post_type' => 'attachment', | |
'post_mime_type' => 'image', | |
'order' => 'ASC', | |
'exclude' => $exclude_thumbnail ? array(get_post_thumbnail_id()) : array(), | |
'orderby' => 'menu_order ID' | |
))); | |
} | |
<?php $photos = kkf_get_images('numberposts=-1', true); ?> | |
<?php if ( $photos ) { | |
foreach ($photos as $photo) { ?> | |
<img src="<?php echo wp_get_attachment_url($photo->ID); ?>" alt="" height="540" width="935"/> | |
<?php } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment