javascript - Fancybox only firing on first gallery -


i using foreach loop inside of wordpress give each image's < rel > tag value of $post_id. creating data variable called 'gallery' value of $post_id. using fancybox call upon data variable , fire fancybox.

this works perfect first image gallery, when go next 1 doesn't fire fancybox though data value , rel tag values match on next galleries.

my jquery:

var galleryvalue = $('.portfolio-gallery').data('gallery');  $("a[rel=" + galleryvalue + "]").fancybox({     'transitionin'      : 'elastic',     'transitionout'     : 'elastic',     'cyclic'        : true,     'autoscale'     : true,     'shownavarrows'     : true,     'overlaycolor'      : '#666'      });  

my html:

<?php $args = array(     'post_type' => 'attachment',     'post_mime_type' => 'image',     'numberposts' => -1,     'post_parent' => $post->id,     'exclude' => get_post_thumbnail_id(), ); ?>  <?php $images = get_posts( $args ); $imageclass = array( 'class' => "gallery-image");  if (!empty($images)) {      foreach($images $image): ?>         <a rel="<?php echo $post->id ?>" class="portfolio-gallery" data-gallery="<?php echo $post->id ?>" href="<?php echo wp_get_attachment_url( $image->id, 'large' ); ?> " title="" >             <?php echo wp_get_attachment_image($image->id, 'singles_thumb', '' ,$imageclass); ?>         </a>     <?php endforeach; ?>  <?php } ?> 

any ideas why fancybox working on first gallery? fancybox in jquery should looking different rel tags start each gallery know i'm doubling on that.

even if not , answer - can not add comment : aim have multiple galleries on 1 page ?

btw - images have same rel - want ? ..

it might helpfull trigger fancybox directly on images - how wordpress :

    //***  start fancybox   -->     jquery(document).ready(function() {     /* apply fancybox multiple items */     jquery('.gallery-icon a,.wp-caption a,.wp-caption-text').attr('rel', 'fancygallery')      //* use following add class dynamically jquery     //** jquery('.gallery-icon a').addclass('fancybox').attr('rel','gallery')       jquery(".gallery-icon a").fancybox({         'my_options_here'   :   'elastic',      });     jquery(".wp-caption a").fancybox({         'my_options_here'   :   'elastic',      }); }); 

Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -