Last active
January 27, 2017 08:25
-
-
Save MinaPansuriya/1f57c0e0d9d932c6bb7f7e61bf50b1c6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @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