Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
/**
* @Title: WooCommerce - List All Products From a specific category
* @Author: Mina Pansuriya
* @Website: http://minapansuriya.com
* @Blog URL: http://minapansuriya.com/woocommerce-list-all-products-from-a-specific-category/
*/
<?php
$cat_name = 'Bags'; // Here replace Category name with yours
$product_cat = get_term_by( 'name', $cat_name, 'product_cat' );
$cat_slug = $product_cat->slug;
$args = array(
'product_cat' => $cat_slug,
'post_type' => 'product',
'orderby' => 'date',
'posts_per_page' => -1
);
$products_list = new WP_query($args);
if ($products_list->have_posts())
{
while ($products_list->have_posts()) : $products_list->the_post();
wc_get_template( 'single-product/title.php' );
endwhile;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment