RtThemesSupport

rttheme17 product loop fix

Aug 2nd, 2013
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.38 KB | None | 0 0
  1. <?php
  2. /*
  3. * rt-theme product loop
  4. */
  5. global $args,$wp_query,$item_width,$content_width,$paged,$box_border,$this_column_width_pixel,$item_width,$cotent_generator,$ajaxScroller;
  6.  
  7. if(is_tax()) $args = array_merge( $wp_query->query, $args);
  8.  
  9. //keep posts
  10. $temp = $wp_query;
  11. $wp_query = null;
  12. $wp_query = new WP_Query();
  13. $wp_query->query( $args );
  14.  
  15.  
  16. //layout names and values
  17. $layout_names      = array("5"=>"five","4"=>"four","3"=>"three","2"=>"two","1"=>"one");
  18.  
  19. //is crop active   
  20. $crop              = get_option(THEMESLUG.'_product_image_crop') ? "true" : "" ;
  21.  
  22. //image max height
  23. $h = $crop ? get_option('rttheme_product_image_height') : 10000;
  24.  
  25. $reset_row_count   = 0;
  26. $counter           = 0;
  27.  
  28. #
  29. #   item width
  30. #
  31. $item_width         =  ($item_width) ?  $item_width  : get_option(THEMESLUG."_product_layout");
  32.  
  33. #
  34. #   column width - pixel  
  35. #
  36. $this_column_width_pixel =  ($this_column_width_pixel) ? intval ($this_column_width_pixel/$item_width) : intval ( ($content_width) / $item_width);
  37. echo '<div class="product_boxes">';
  38. if ( $wp_query -> have_posts() ) : while ( $wp_query -> have_posts() ) : $wp_query -> the_post();
  39.  
  40.     // featured images
  41.     $rt_gallery_images          = get_post_meta( $post->ID, THEMESLUG . "rt_gallery_images", true );
  42.     $rt_gallery_image_titles    = get_post_meta( $post->ID, THEMESLUG . "rt_gallery_image_titles", true );
  43.     $rt_gallery_image_descs     = get_post_meta( $post->ID, THEMESLUG . "rt_gallery_image_descs", true );
  44.  
  45.     // Values
  46.     $image          =   (is_array($rt_gallery_images)) ? find_image_org_path($rt_gallery_images[0]) : "";
  47.     $title          =   get_the_title();
  48.     $desc           =   get_post_meta($post->ID, THEMESLUG.'product_desc', true);
  49.     $permalink      =   get_permalink();
  50.     $short_desc     =   get_post_meta($post->ID, THEMESLUG.'short_description', true);
  51.     $custom_thumb   =   get_post_meta($post->ID, THEMESLUG.'product_thumb_image', true);
  52.  
  53.     //box counter
  54.     if(!isset($box_counter)) $box_counter = 1;
  55.  
  56.     //this column width - grid
  57.     $this_column_width_grid = 60 / $item_width;
  58.    
  59.     // Reset Counter   
  60.     $reset=false;
  61.     $reset_row_count =  $reset_row_count + $this_column_width_grid;
  62.  
  63.  
  64.     //Thumbnail dimensions
  65.     $w = ($this_column_width_pixel > 600) ? 940 : (($this_column_width_pixel > 400) ? 440 : 420);  
  66.  
  67.     // Resize Image
  68.     if($image) $image_thumb = @vt_resize( '', $image, $w, $h, ''.$crop.'' );
  69.  
  70.     // fixed row holder        
  71.     if($box_counter ==1) echo '<div class="fixed-row">';   
  72.      
  73.        
  74.     //firt and last
  75.     if($item_width==1){
  76.         $addClass        ="first";
  77.         $addClass        .=" last";
  78.         $box_counter     =0;
  79.         $reset_row_count = 0;      
  80.     }  
  81.     elseif($box_counter==1){
  82.         $addClass ="first";
  83.     }  
  84.     elseif ($reset_row_count+$this_column_width_grid > 60){
  85.         $addClass        ="last";
  86.         $box_counter     =0;
  87.         $reset_row_count = 0;
  88.     }
  89.     else{
  90.         $addClass ="";
  91.     }
  92.  
  93. ?>
  94.  
  95.     <!-- product -->
  96.     <div class="box <?php echo $layout_names[$item_width];?> <?php echo $addClass;?> product box-shadow">
  97.             <?php if($image):?>
  98.             <!-- product image -->
  99.             <a href="<?php echo $permalink;?>" class="imgeffect link"><img src="<?php echo $image_thumb['url'];?>"  alt="<?php echo $title;?>" /></a>
  100.  
  101.             <div class="image-border-bottom"></div><!-- the underline for the image  -->   
  102.             <?php endif;?>
  103.            
  104.             <div class="product_info">
  105.             <!-- title-->
  106.             <h5><a href="<?php echo $permalink;?>" title="<?php echo $title;?>"><?php echo $title;?></a></h5>              
  107.             <!-- text-->
  108.             <?php echo (do_shortcode($short_desc));?>              
  109.         </div>
  110.     </div>
  111.     <!-- / product -->
  112.      
  113.  
  114.            
  115. <?php
  116. //get page and post counts
  117. $page_count=get_page_count();
  118. $post_count=$page_count['post_count'];
  119.    
  120.     $counter++;
  121.     $box_counter++;
  122.    
  123.     //close row
  124.     if(stristr($addClass,"last") || $post_count==$counter){
  125.        
  126.         echo "</div><!-- end of fixed rows -->";//end of fixed rows
  127.  
  128.         if ($post_count!=$counter){
  129.             echo '<div class="clear"></div><div class="space margin-b30"></div>';
  130.         }
  131.     }    
  132.  
  133. ?>
  134.  
  135. <?php endwhile;endif;?>
  136. </div>
  137.  
  138.  
  139. <?php if( isset( $page_count['page_count'] ) && $page_count['page_count'] >1 && $paged):?>
  140.  
  141. <!-- paging-->
  142. <div class="clear"></div>
  143.     <div class="paging_wrapper margin-t30">
  144.         <ul class="paging">
  145.             <?php
  146.             if($ajaxScroller){
  147.                 get_pagination(1000,"true");
  148.             }else{
  149.                 get_pagination();
  150.             }?>
  151.         </ul>
  152.     </div>         
  153.     <!-- / paging-->
  154. <?php endif;?>
  155.  
  156.  
  157. <?php
  158.   $wp_query = null;
  159.   $wp_query = $temp;  // Reset
  160. ?>
  161.  
  162.  
  163. <?php wp_reset_query(); ?>
Advertisement
Add Comment
Please, Sign In to add comment