attachment.php template and flexslider—linking to specific image
-
Hi Everyone!
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). The user should then be able to scroll through the remaining attached images using flexslider. So far, this is all working correctly—in principle.
The problem is that the thumbnail link takes 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"> <?php 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>'; } } ?> </ul> </div>
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):
https://www.adamprince.us/clients/mcnairevans/projects/confessions-for-a-son/
Many thanks!!!
- The topic ‘attachment.php template and flexslider—linking to specific image’ is closed to new replies.