Advertisement
iEmanuele

Gallery-thumbnail

Aug 6th, 2013
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.30 KB | None | 0 0
  1. <?php
  2.     //////////////////////////////////////////////////////////////
  3.     // This is the file from which you do "get_template_part()" //
  4.     //////////////////////////////////////////////////////////////
  5. ?>
  6.  
  7. <?php
  8.        
  9.     //// GETS OUR IMAGES
  10.     $query_images_args = array(
  11.         'post_type' => 'attachment',
  12.             'post_mime_type' =>'image',
  13.             'post_status' => 'inherit',
  14.             'posts_per_page' => -1,
  15.             'post_parent' => get_the_ID(),
  16.             'exclude' => get_post_thumbnail_id(),
  17.             'orderby' => 'menu_order',
  18.             'order' => 'ASC'
  19.     );
  20.        
  21.     //All objects Image, less the featured image
  22.         $images = get_posts( $query_images_args );
  23.    
  24.     //Randomly choose a key from within the $images array
  25.     $key = array_rand( $images, 1 );
  26.        
  27.     //Get the image id, corresponding to the previous key
  28.     $imageID = $images[$key]->ID;
  29.    
  30.     //The url of that image
  31.     $featured_image = wp_get_attachment_url($imageID);
  32. ?>
  33.  
  34. <div id="property-gallery">
  35.  
  36.         <a class="image" href="<?php echo $featured_image ?>" rel="lightbox[gal]" title="<?php the_title(); ?>"><img src="<?php echo ddTimthumb($featured_image, 680, 450) ?>" title="<?php the_title(); ?>" alt="<?php the_title(); ?>" /></a>
  37.    
  38.     <div id="property-info">
  39.                                
  40.         <div class="left">
  41.             <?php if(get_post_meta(get_the_ID(), 'bedrooms', true)!='') : ?><span class="beds"><?php echo get_post_meta(get_the_ID(), 'bedrooms', true); ?></span><?php endif; ?>
  42.             <?php if(get_post_meta(get_the_ID(), 'bathrooms', true)!='') : ?><span class="baths"><?php echo get_post_meta(get_the_ID(), 'bathrooms', true); ?></span><?php endif; ?>
  43.             <?php if(get_post_meta(get_the_ID(), 'car_spaces', true)!='') : ?><span class="cars"><?php echo get_post_meta(get_the_ID(), 'car_spaces', true); ?></span><?php endif; ?>
  44.         </div>
  45.         <!-- /.left/ -->
  46.        
  47.         <div class="right">Töötasu: <?php echo format_property_price(get_post_meta(get_the_ID(), 'price', true), get_the_ID()); ?></div>
  48.    
  49.     </div>
  50.     <!-- /#property-info/ -->
  51.  
  52. </div>
  53. <!-- /#property-gallery/ -->
  54. <?php
  55.  
  56.         ///////////////////////////////////////////////////////
  57.         //// GALLERYTHUMBS FOR RESPONSIVE DESIGN
  58.         ///////////////////////////////////////////////////////
  59.        
  60.         get_template_part('includes/properties/single', 'gallery-responsive');
  61.        
  62.         ///////////////////////////////////////////////////////
  63.        
  64.  
  65. ?>            
  66. <?php
  67.    
  68.     //////////////////////////////////////////////////////////////////////////
  69.     // The thumbnails gallery template begins here : gallery-responsive.php//
  70.     ////////////////////////////////////////////////////////////////////////
  71.    
  72.    
  73.     //// GETS OUR IMAGES
  74.     $query_images_args = array(
  75.  
  76.        'post_type' => 'attachment',
  77.        'post_mime_type' =>'image',
  78.        'post_status' => 'inherit',
  79.        'posts_per_page' => -1,
  80.        'post_parent' => get_the_ID(),
  81.        'exclude' => get_post_thumbnail_id(),
  82.        'orderby' => 'menu_order',
  83.        'order' => 'ASC',
  84.  
  85.     );
  86.     //All objects Image, less the featured image
  87.     $images = get_posts( $args );
  88.  
  89.     ?>
  90.  
  91.     <div class="sidebar-item not-in-responsive">
  92.  
  93.         <script type="text/javascript">
  94.  
  95.             jQuery(document).ready(function() {
  96.  
  97.                 jQuery('#property-gallery-thumbs').propertyGallery();
  98.  
  99.             });
  100.  
  101.         </script>
  102.  
  103.     <ul id="property-gallery-thumbs">
  104.  
  105.     <?php
  106.  
  107.         $i = 1;    
  108.         /// IF WE HAVE MORE THAN JUST ONE IMAGE
  109.         if( $images ) : foreach( $images as $image ) : setup_postdata( $image ); ++$i;
  110.  
  111.     ?>
  112.  
  113.             <li class="thumb<?php if($i==1) { echo ' current'; } ?><?php if($i%3 == 0) { echo ' last'; } ?>">
  114.  
  115.                 <span class="hidden full"><?php echo wp_get_attachment_url( $image->ID ); ?></span>
  116.                 <span class="hidden main"><?php echo ddTimthumb(wp_get_attachment_url( $image->ID ), 680, 450); ?></span>
  117.                 <span class="thumb"><img src="<?php echo ddTimthumb(wp_get_attachment_url( $image->ID ), 76, 76); ?>" alt="<?php the_title() ?>" title="<?php the_title(); ?>" /></span>
  118.  
  119.             </li>
  120.  
  121.         <?php endforeach; wp_reset_postdata(); ?>
  122.  
  123.     </ul>
  124.     <!-- /#property-gallery-thumbs/ -->
  125.  
  126. </div>
  127.  
  128.     <?php endif; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement