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.

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; ?>
share|improve this question
add comment

1 Answer 1

up vote 1 down vote accepted

I think you can use the_attachment_link or wp_get_attachment_link.

http://codex.wordpress.org/Function_Reference/wp_get_attachment_link
http://codex.wordpress.org/Function_Reference/the_attachment_link

Example

the_attachment_link( $photo->ID, false, false, true );
share|improve this answer
    
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
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.