sagive

specials custom post type loop

Mar 24th, 2012
93
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. $c = 0;
  3. while (have_posts()) : the_post();
  4. $c++;
  5.  
  6. if($c == 4) {
  7. $style = 'ml0';
  8. $c = 0;
  9. } else { $style=''; }
  10.  
  11. $post_type = get_post_type( $post->ID );
  12.  
  13. if ($post_type == 'engagement_ring') {
  14. $metaVar = 'engagement_ring';
  15. } elseif ($post_type == 'wedding_ring') {
  16. $metaVar = 'wedding_ring';
  17. } elseif ($post_type == 'pendants') {
  18. $metaVar = 'pendant';
  19. } elseif ($post_type == 'earrings') {
  20. $metaVar = 'earring';
  21. } elseif ($post_type == 'bracelets') {
  22. $metaVar = 'bracelet';
  23. }
  24.  
  25. /* GET VARIBLES */
  26. $inventory = get_post_meta($post->ID, '_cmb_'.$metaVar.'_inventory', true);
  27. $preDiscount = get_post_meta($post->ID, '_cmb_'.$metaVar.'_regular_price', true);
  28. $discount = get_post_meta($post->ID, '_cmb_'.$metaVar.'_discounted_price', true);
  29. $description = get_post_meta($post->ID, '_cmb_'.$metaVar.'_description', true);
  30.  
  31. ?>
  32. <div class="relatedProducts">
  33. <div class="releatedProduct <?php echo $style; ?>">
  34. <!--===END=== THUMBNAIL ========-->
  35. <?php
  36. $image_id = get_post_thumbnail_id();
  37. $image_url = wp_get_attachment_image_src($image_id,'large');
  38. $image_url = $image_url[0];
  39. ?>
  40. <a title="<?php the_title(); ?>" href="<?php echo $image_url; ?>" class="lightbox">
  41. <span class="rollRelated" ></span>
  42. <?php echo get_the_post_thumbnail($post->ID, 'releated'); ?>
  43. </a>
  44. <!--===END=== THUMBNAIL ========-->
  45. <div class="productTitle"><a href="<?php the_permalink(); ?>"><?php echo mb_substr(get_the_title(), 0, 28); ?></a></div>
  46.  
  47. <div class="productDescription"><?php echo mb_substr($description, 0, 80); ?>...</div>
  48. <div class="readmore"><a href="<?php the_permalink(); ?>" rel="nofollow"><?php _e('Read More', 'sagive'); ?></a></div>
  49. </div>
  50. </div>
  51.  
  52. <?php endwhile;?>
  53. <div class="navigation"><?php wp_pagenavi(); ?></div>
RAW Paste Data