How to get Products of Product category WooCommerce by slug

This tutorial will help you custom WooCommerce theme in WordPress theme and how to get Products of Category in WooCommerce by slug

	$categories = 'shoes,tshirt';
		$all_category = explode(',', $categories);
		foreach ($all_category as $category)
			$term = get_term_by('slug', $category, 'product_cat');
			echo '<div class="row">
			<div class="product-category"><h3 class="title-widget"><span>'.'<a href="'. get_term_link($category, 'product_cat') .'">'. $term->name .'</a>'.'</span></h3></div>';

			echo '<div class="product-block-content clearfix">';
			include(TEMPLATEPATH. '/includes/templates/home-product-loop.php');
			echo '</div></div>';

Product Loop Query in /includes/templates/home-product-loop.php

$argss = array(
		'posts_per_page' => 8,
		'product_cat' => $category,
		'post_type' => 'product',
		'orderby' => 'modified',
$the_query_product = new WP_Query( $argss );
// The Loop
while ( $the_query_product->have_posts() ) {

<div class="col-lg-3 col-sm-6 col-xs-6">
	<div class="product-block" itemscope itemtype="">
		<div class="thumbnail-item">
		<a href="<?php echo permalink_link()?>">
		<?php the_post_thumbnail('full', array('class' => 'img-responsive','itemprop'=>'image')); ?>
		<div class="tooltip hidden-xs">
			<?php the_post_thumbnail(array(300,300)); ?>
			<div class="short-description">
			<?php echo apply_filters( 'woocommerce_short_description', $post->post_excerpt ) ?>
		<h4 class="entry-title" itemprop="name"><a href="<?php the_permalink(); ?>" itemprop="url"><?php the_title(); ?></a></h4>
		<span class="price"><?php echo $product->get_price_html(); ?></span>

Share this :

Comments are closed.

Related post

Free Responsive Website templates

ThemeVina is Best site for free sharing and download Wordpress themes, Joomla templates, Responsive website templates and more HTML templates.

All template in Site are free. You can download and install for your site.

Contact us

  • Brand: Theme Vina
  • Email:
  • Website:
  • Address: 367 Tran Hung Dao Street
  • Location: Thai Binh City, Thai Binh, Viet Nam