Skip to content

Instantly share code, notes, and snippets.

@habibimroncn
Forked from ciorici/index.php
Created April 7, 2022 04:36
Show Gist options
  • Save habibimroncn/86bc1591425d583cee4d17d3005061ad to your computer and use it in GitHub Desktop.
Save habibimroncn/86bc1591425d583cee4d17d3005061ad to your computer and use it in GitHub Desktop.
Featured Products Loop in WooCommerce 3.0
<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-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment