• What I want to do: when you click the featured image on a post a lightbox opens and shows all the images added as attachment to the post (the images when you check under the ‘gallery’ section of the upload module)

    So far I got the featured image working and it opens in a lightbox (I’m working with prettyPhoto). I also was able to query for the attached images and got them to display on the page.

    <?php  $args = array(
       'post_type' => 'attachment',
       'numberposts' => -1,
       'post_status' => null,
       'post_parent' => $post->ID
      );
      ?>
    <?php
    	$attachments = get_posts( $args );
    	if ( $attachments ) {
    	foreach ( $attachments as $attachment ) {
    	echo '<p>';
    	echo wp_get_attachment_image( $attachment->ID, 'thumb' );
    	echo '</p>';
    
    		}
    	}?>

    What I can’t figure out is:
    a) how to link those images to their url so they can be shown in a lightbox
    b) how to make sure only the ‘featured image’ (or the first image) is displayed but links to the other images in the lightbox.

    I’m having a hunch that I’m going about this the wrong way. Anyone have suggestions or pointers? Thanks!

  • The topic ‘Link featured image to lightbox gallery of post images’ is closed to new replies.