Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate
Sign In | Create Account

custom_product-cat
Thursday, December 20th, 2012 at 11:32:54am UTC 

  1. <?php if($category->count == 1){
  2.  
  3. $query_args = array( 'showposts'=>1,'post_status' => 'publish', 'post_type' => 'product', 'tax_query' => array(
  4. array(
  5. 'taxonomy' => 'product_cat',
  6. 'field' => 'slug',
  7. 'terms' => $category
  8. )));
  9. $r = new WP_Query($query_args);
  10.  
  11. if ($r->have_posts()) {
  12. ?>
  13. <?php while ($r->have_posts()) : $r->the_post(); global $product;
  14. $category_link = get_permalink() ;
  15. endwhile; ?>
  16. <?php
  17. // Reset the global $the_post as this query will have stomped on it
  18. wp_reset_query();
  19.  
  20. } else {$category_link = $category_link = get_term_link( $category->slug, 'product_cat' );}
  21.  
  22. }else{$category_link = get_term_link( $category->slug, 'product_cat' );}?>
  23. <?php
  24. /**
  25.  * The template for displaying product category thumbnails within loops.
  26.  *
  27.  * Override this template by copying it to yourtheme/woocommerce/content-product_cat.php
  28.  *
  29.  * @package WooCommerce
  30.  * @since WooCommerce 1.6
  31.  */
  32.  
  33. global $woocommerce_loop;
  34.  
  35. // Store loop count we're currently on
  36. if ( empty( $woocommerce_loop['loop'] ) )
  37.         $woocommerce_loop['loop'] = 0;
  38.  
  39. // Store column count for displaying the grid
  40. if ( empty( $woocommerce_loop['columns'] ) )
  41.         $woocommerce_loop['columns'] = of_get_option('shop_cols');
  42.  
  43. // Increase loop count
  44. $woocommerce_loop['loop']++;
  45. ?>
  46.  
  47. <div class="grid<?php echo of_get_option('shop_cols', '3'); ?>column <?php
  48.         if ( $woocommerce_loop['loop'] % $woocommerce_loop['columns'] == 0 )
  49.                 echo 'lastcolumn';
  50.         elseif ( ( $woocommerce_loop['loop'] - 1 ) % $woocommerce_loop['columns'] == 0 )
  51.                 echo 'first';
  52.         ?>">
  53.  
  54.         <?php do_action( 'woocommerce_before_subcategory', $category ); ?>
  55.                
  56.                
  57.                 <div class="item-container shop-item-zoom">
  58.                        
  59.                         <div class="item-container-image item-container-spacer">
  60.                        
  61.                        
  62.                         <?php if(of_get_option('hover_icon_display_shop', 'yes') == 'yes'): ?>
  63.                        
  64.                         <a href="<?php echo $category_link; ?>" class="zoom-icon zoom-icon-article"></a>
  65.                        
  66.                         <?php endif; ?>
  67.                         <a href="<?php echo $category_link; ?>">
  68.                         <?php
  69.                                 /**
  70.                                  * woocommerce_before_subcategory_title2 hook
  71.                                  *
  72.                                  * @hooked woocommerce_subcategory_thumbnail2 - 10
  73.                                  */      
  74.                                 do_action( 'woocommerce_before_subcategory_title2', $category );
  75.                         ?>     
  76.                         </a>
  77.                         </div>
  78.                        
  79.                         <div class="item-container-content">
  80.                                 <h4 class="aligncenter">
  81.                                 <a href="<?php echo $category_link; ?>">
  82.                                 <?php echo $category->name; ?>
  83.                                 <?php if ( $category->count > 0 ) : ?>
  84.                                         <mark class="count">(<?php echo $category_link; ?>)</mark>
  85.                                 <?php endif; ?>
  86.                                 </a>
  87.                                 </h4>
  88.                                 <div class="aligncenter description-index"><div itemprop="description">
  89. <?php echo $category->description; ?></div></div>
  90.                        
  91.                         <div class="aligncenter">
  92.                       <a href="<?php echo $category_link; ?>" class="def-button arrow-button category-button"><?php _e('View Category','woocommerce'); ?></a>
  93.                         </div> 
  94.                                
  95.                                 <?php
  96.                                         /**
  97.                                          * woocommerce_after_subcategory_title hook
  98.                                          */      
  99.                                         do_action( 'woocommerce_after_subcategory_title', $category );
  100.                                 ?>
  101.                                
  102.                                
  103.                         </div><!-- close .item-container-content -->
  104.                 </div><!-- close .item-container -->
  105.                
  106.                
  107.                
  108.                
  109.        
  110.        
  111.        
  112. </div>
  113. <?php
  114.         if ( $woocommerce_loop['loop'] % $woocommerce_loop['columns'] == 0 )
  115.                 echo '<div class="clearfix"></div><br>';
  116.         elseif ( ( $woocommerce_loop['loop'] - 1 ) % $woocommerce_loop['columns'] == 0 )
  117.                 echo '';
  118. ?>     
  119.        
  120.        
  121.        
  122.        
  123.        
  124.        
  125.        
  126.        
  127.         <?php do_action( 'woocommerce_after_subcategory', $category ); ?>                     

Update the Post

Either update this post and resubmit it with changes, or make a new post.

You may also comment on this post.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.

comments powered by Disqus
worth-right
worth-right
worth-right