Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • #3672
    Stephen S

    Hi, I have created a custom archive loop which pulls attachment images for each post and puts each in it’s own div. Unfortunately, Responsive lightbox is setting the same rel= lightbox ID for each of them, resulting in all images being shown together. What I want is for each post to have its own gallery id. Any suggestions?


    Stephen S

    Nevermind, I solved this by hand coding the post id as gallery id like so in my loop:

    if ( $attachments ) {
    			foreach ( $attachments as $attachment ) {
    				$class = "post-attachment mime-" . sanitize_title( $attachment->post_mime_type );
    				$thumbimg = wp_get_attachment_link( $attachment->ID, 'featured-photo', true );
    				$thumbimg = preg_replace("/<a/","<a rel=\"lightbox[gallery-".$post->ID."]\"",$thumbimg,1);
    				echo '<li class="' . $class . ' data-design-thumbnail">' . $thumbimg . '</li>';

    Nice code Stephen :)

    There’s also a wp_get_attachment_link filter you could use I think (http://hitchhackerguide.com/2011/02/12/wp_get_attachment_link/), but this above gives you complete control over the display.

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.