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.


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:


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

  • 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 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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