Created
March 6, 2012 23:29
-
-
Save lumpysimon/1989756 to your computer and use it in GitHub Desktop.
wordpress get attached images slideshow
This file contains 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
$args = array( | |
'post_parent' => $post->ID, | |
'post_type' => 'attachment', | |
'post_mime_type' => 'image/jpeg', | |
'orderby' => 'menu_order', | |
'order' => 'ASC', | |
'posts_per_page' => -1 | |
); | |
$slides = get_posts( $args ); | |
if ( $slides ) { | |
$out .= '<div id="slides">'; | |
foreach ( $slides as $slide ) { | |
$src = wp_get_attachment_image_src( $slide->ID, 'carousel' ); | |
$out .= '<div class="slide" id="slide-' . $slide->ID . '">'; | |
$out .= '<div class="slide-image"><img src="' . $src[0] . '" width="' . $src[1] . '" height="' . $src[2] . '"></div>'; | |
$out .= '</div>'; | |
} | |
$out .= '</div>'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment