Created
January 29, 2014 06:57
-
-
Save hectorlorenzo/8683108 to your computer and use it in GitHub Desktop.
Simple Wordpress function to get the attached images that belong to a specific post.
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
// get all attachments from a post, except the featured image | |
function get_attached_images ( $post_ID, $featured_image = false ) { | |
$args = array( | |
'post_type' => 'attachment', | |
'posts_per_page' => -1, | |
'post_parent' => $post_ID | |
); | |
// do we want the featured image? | |
if (!$featured_image) { | |
$args['post__not_in'] = array(get_post_thumbnail_id( $post_ID )); | |
} | |
$att_images = get_posts( $args ); | |
return $att_images; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment