-
-
Save anonymous/02f423c21cfb053b2399 to your computer and use it in GitHub Desktop.
WPAlchemy - Adding thumbnail to shadowbox gallery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php global $mgallery; ?> | |
<?php $loop = new WP_Query( array( 'post_type' => 'gallery_main', 'posts_per_page' => -1, 'orderby'=> 'date', 'order' => 'DESC' ) ); ?> | |
<?php while ($loop->have_posts()) { ?> | |
<?php $loop->the_post(); $mgallery->the_meta($post->ID); ?> | |
<div class="mgallery"> | |
<?php $gallery_images = $mgallery->get_the_value('gallery_image'); ?> | |
<?php $i = 0; foreach ($gallery_images as $w) { ?> | |
<?php //get the attachment id dynamically to use with wp_get_attachment_id | |
global $wpdb; $attachment_id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_parent = '$post->ID' AND post_status = 'inherit' AND post_type='attachment' ORDER BY post_date DESC LIMIT 1"); | |
$attach = wp_get_attachment_image_src( $attachment_id, 'thumbnail' ); | |
//$attach[0] => url | |
//$attach[1] => width | |
//$attach[2] => height | |
?> | |
<a rel="shadowbox[<?php $galleryname = get_post_meta($post->ID,'_gallery_name',TRUE); echo $galleryname['galleryname']; ?>]" href="<?php echo $w['imgurl']; ?>" title="<?php echo $w['title']; ?>"><img class="gimage<?php echo (!$i) ? ' first' : '' ; ?>" src="<?php echo $attach[0]; ?>" width="<?php echo $attach[1]; ?>" height="<?php echo $attach[2]; ?>" alt="<?php echo $w['title']; ?>"/></a> | |
<?php $i++; } ?> | |
<div class="gtitle"> | |
<a rel="shadowbox[<?php echo $w['gname']; ?>]" href="<?php echo $w['imgurl']; ?>" title="<?php echo $w['title']; ?>"><?php the_title(); ?></a> | |
</div><!-- end gtitle --> | |
</div><!-- end mgallery --> | |
<?php } ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment