Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
wordpress get attached images slideshow
$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
You can’t perform that action at this time.