Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

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

share|improve this answer
    
Thanks! Seems to be a good solution. Do you know how to remove the featured image from those attachments? Is it possible to do so? –  João Ramos Apr 5 '12 at 14:40
1  
Grab the ID of the featured image ( it's stored int he post meta _thumbnail_id) and if $attachment->ID is equal to that ID, do not process that attachment and move on to the next –  Tom J Nowell Apr 5 '12 at 14:42
    
Thanks! Worked like a charm! –  João Ramos Apr 5 '12 at 17:57
    
Nice =] can you accept this answer if everything is working as intended? –  Tom J Nowell Apr 5 '12 at 18:15
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.