attachment.php & flexslider—linking thumbnail to specific image


I am nearly there but need the help of the community to bring me home! I am linking from a “gallery overview” page (thumbnail grid) to a single, full-size image page (attachment.php) containing a slideshow. The user should then be able to use flexslider to scroll through the additional attached images. So far, this is all working correctly—in principle.

The problem is that clicking on any thumbnail brings the user to the FIRST image in the gallery, rather than the actual image represented by the thumbnail. My attachment.php code is as follows:

<div id="slider" class="slider">
    <ul class="slides-init">
            global $post;
            $args = array(
                'post_type' => 'attachment',
                'numberposts' => -1,
                'post_status' => null,
                'post_parent' => $post->post_parent,
                'order_by' => 'menu_order',
                'order' => 'ASC'
            $attachments = get_posts($args);
            if ($attachments) {
                foreach ($attachments as $attachment) {
                    echo '<li>';
                    echo wp_get_attachment_image($attachment->ID, 'large');
                    echo '</li>';

Any help would be greatly appreciated. Also, the test site can be found here (simply click on one of the thumbnails to see what I mean):

Many thanks!!!

, , , Adam 9 years 2014-08-06T16:52:41-05:00 0 Answers 89 views 0

Leave an answer