Advertisement
developerjustin

Untitled

Jun 17th, 2014
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.22 KB | None | 0 0
  1.                                 $children = get_term_children($wp_query->queried_object->term_id, $wp_query->queried_object->taxonomy);
  2.                                
  3.                                 if($children){
  4.                                     //print_r($wp_query->posts);
  5.                                     foreach($children as $subcat){
  6.                                    
  7.                                         $term = get_term($subcat,$wp_query->queried_object->taxonomy);
  8.                                        
  9.                                         $IDs = '';
  10.    
  11.                                         $args = array(
  12.                                             'post_type' => 'product',
  13.                                             'posts_per_page'=>3,
  14.                                             'product_cat' => $term->slug
  15.                                         );
  16.                                         $sub_query = new WP_Query( $args );
  17.                                        
  18.                                         // The Loop
  19.                                         if ( $sub_query->have_posts() ) {
  20.                                            
  21.                                             ?>
  22.                                            
  23.                                                 <h2><?php echo $term->name; ?></h2>
  24.                                            
  25.                                             <?php
  26.                                            
  27.                                             $link = get_term_link($term->term_id,$wp_query->queried_object->taxonomy);
  28.                                        
  29.                                             while ( $sub_query->have_posts() ) {
  30.                                                 $sub_query->the_post();
  31.    
  32.                                                 $IDs .= ",".$post->ID;
  33.                                             }
  34.                                            
  35.                                             echo do_shortcode('[products ids="'.$IDs.'"]');
  36.                                            
  37.                                             ?>
  38.                                            
  39.                                                 <a href="<?php echo $link; ?>" class="all">View All <?php echo $term->name; ?></a>
  40.                                            
  41.                                             <?php
  42.                                         }                                      
  43.                                     }                                  
  44.                                 }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement