Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $children = get_term_children($wp_query->queried_object->term_id, $wp_query->queried_object->taxonomy);
- if($children){
- //print_r($wp_query->posts);
- foreach($children as $subcat){
- $term = get_term($subcat,$wp_query->queried_object->taxonomy);
- $IDs = '';
- $args = array(
- 'post_type' => 'product',
- 'posts_per_page'=>3,
- 'product_cat' => $term->slug
- );
- $sub_query = new WP_Query( $args );
- // The Loop
- if ( $sub_query->have_posts() ) {
- ?>
- <h2><?php echo $term->name; ?></h2>
- <?php
- $link = get_term_link($term->term_id,$wp_query->queried_object->taxonomy);
- while ( $sub_query->have_posts() ) {
- $sub_query->the_post();
- $IDs .= ",".$post->ID;
- }
- echo do_shortcode('[products ids="'.$IDs.'"]');
- ?>
- <a href="<?php echo $link; ?>" class="all">View All <?php echo $term->name; ?></a>
- <?php
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement