Created
April 27, 2017 08:10
-
-
Save ciorici/5a9a8a8ed1545e15ea8b2d55b3b46f6a to your computer and use it in GitHub Desktop.
Featured Products Loop in WooCommerce 3.0
This file contains 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
<ul class="products"> | |
<?php | |
$args = array( | |
'post_type' => 'product', | |
'posts_per_page' => 12, | |
'tax_query' => array( | |
array( | |
'taxonomy' => 'product_visibility', | |
'field' => 'name', | |
'terms' => 'featured', | |
), | |
), | |
); | |
$loop = new WP_Query( $args ); | |
if ( $loop->have_posts() ) { | |
while ( $loop->have_posts() ) : $loop->the_post(); | |
wc_get_template_part( 'content', 'product' ); | |
endwhile; | |
} else { | |
echo __( 'No products found' ); | |
} | |
wp_reset_postdata(); | |
?> | |
</ul><!--/.products--> |
Thank you!
And how to get all products except featured ones? Thank you.
Never mind. It's done. I just added the 'operator' => 'NOT IN',
after terms
Does somebody knows how to list my hidden products?
Thank you! This really help me!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for de code.