I am running this query which pulls all of the images attached to a particular post and outputs them into a slideshow (See example here - http://powers.deanelliott.me/property/1428-elm-street/)

Is there a way that I can directly output a link (So that the larger image gets displayed in a lightbox) into this query as adding link tags doesn't seem to work

<?php $args = array('numberposts' => -1, 'orderby' => 'menu_order', 'order' => 'ASC', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'post_parent' => $post->ID); ?>
    <?php if ( $photos = get_posts($args) ) : ?>
        <?php foreach ( $photos as $photo ) : ?>
            <?php echo wp_get_attachment_image($photo->ID,'thumbnail'); ?>
        <?php endforeach; ?>
    <?php endif; ?>

I think you can use the_attachment_link or wp_get_attachment_link.



the_attachment_link( $photo->ID, false, false, true );
  • How would I include that in the original query though without having to use <a href="#"></a> which is where the problem lies – Dean Elliott Dec 14 '11 at 10:23

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.