Friday, January 27, 2017

Lists all the Posts from Current Taxonomy

<?php $term = $wp_query->queried_object;
   $getterm = $term->slug;
?>
<?php $args = array(
    'post_type' => 'product',
  'tax_query' => array(
      array(
          'taxonomy' => 'product_category',
          'terms' => $getterm,
          'field' => 'slug',
      )
  ),
    );
$product_latest = new WP_Query( $args ); ?>
<?php while( $product_latest->have_posts() ): $product_latest->the_post(); ?>
 // Your content goes here
<?php endwhile; ?>

No comments:

Post a Comment