Advertisement
bmex63

WooCommerce Image Gallery Order

Nov 28th, 2011
945
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. if (!function_exists('woocommerce_show_product_thumbnails')) {
  2. function woocommerce_show_product_thumbnails() {
  3.  
  4. global $_product, $post;
  5.  
  6. echo '<div class="thumbnails">';
  7.  
  8. $thumb_id = get_post_thumbnail_id();
  9. $small_thumbnail_size = apply_filters('single_product_small_thumbnail_size', 'shop_thumbnail');
  10. $args = array(
  11. 'post_type' => 'attachment',
  12. 'order' => 'ASC',
  13. 'orderby' => 'menu_order ID',
  14. 'numberposts' => -1,
  15. 'post_status' => null,
  16. 'post_parent' => $post->ID,
  17. 'post__not_in' => array($thumb_id),
  18. 'post_mime_type' => 'image',
  19. 'meta_query' => array(
  20. array(
  21. 'key' => '_woocommerce_exclude_image',
  22. 'value' => '1',
  23. 'compare' => '!='
  24. )
  25. )
  26. );
  27. $attachments = get_posts($args);
  28. if ($attachments) :
  29. $loop = 0;
  30. $columns = apply_filters('woocommerce_product_thumbnails_columns', 3);
  31. foreach ( $attachments as $attachment ) :
  32.  
  33. $loop++;
  34.  
  35. $_post = & get_post( $attachment->ID );
  36. $url = wp_get_attachment_url($_post->ID);
  37. $post_title = esc_attr($_post->post_title);
  38. $image = wp_get_attachment_image($attachment->ID, $small_thumbnail_size);
  39.  
  40. echo '<a href="'.$url.'" title="'.$post_title.'" rel="thumbnails" class="zoom ';
  41. if ($loop==1 || ($loop-1)%$columns==0) echo 'first';
  42. if ($loop%$columns==0) echo 'last';
  43. echo '">'.$image.'</a>';
  44.  
  45. endforeach;
  46. endif;
  47. wp_reset_query();
  48.  
  49. echo '</div>';
  50.  
  51. }
  52. }
  53.  
  54.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement