How to create a simple slideshow out of a post image gallery?

Are there any solutions to transform a default image gallery into a simple slideshow as seen in this theme?

Note: click to move to the next picture in the gallery.

Related posts

Leave a Reply

1 comment

  1. Yes, you can use any slider jquery plugin you wish, but to feed the slideshow you need the photos.

    Galleries in WordPress are composed of posts with post_type attachment, and attachments that are attached to a post have that posts ID as their post_parent. So to get the images for the slideshow or slider, you need to find posts, that are of post_type attachment, and are children of the current post.

    This article has more information on attachments:

    http://digwp.com/2009/08/awesome-image-attachment-recipes-for-wordpress/

    If you browse to the bottom of the article there is code to grab all the attachments attached to the current post:

    $args = array(
        'order'          => 'ASC',
        'post_type'      => 'attachment',
        'post_parent'    => $post->ID,
        'post_mime_type' => 'image',
        'post_status'    => null,
        'numberposts'    => -1,
    );
    $attachments = get_posts($args);
    if ($attachments) {
        foreach ($attachments as $attachment) {
            echo apply_filters('the_title', $attachment->post_title);
            echo wp_get_attachment_link($attachment->ID, 'thumbnail', false, false);
        }
    }
    

    This can be used as a basis for generating the markup for the slideshow/slider by modifying the html in the post loop.

    This question deals with using nivoslider and image attachments:

    Loop through child images of a parent for a Nivo Slider