Skip to content

Instantly share code, notes, and snippets.

@webdev1001
Forked from lmartins/front-page.php
Last active August 29, 2015 14:11
Show Gist options
  • Save webdev1001/0798bf1bd494c0f78ba9 to your computer and use it in GitHub Desktop.
Save webdev1001/0798bf1bd494c0f78ba9 to your computer and use it in GitHub Desktop.
<?php
$args = array(
'post_type' => 'product',
'meta_query' => array(
'relation' => 'OR',
array( // Simple products type
'key' => '_sale_price',
'value' => 0,
'compare' => '>',
'type' => 'numeric'
),
array( // Variable products type
'key' => '_min_variation_sale_price',
'value' => 0,
'compare' => '>',
'type' => 'numeric'
)
)
);
$featured_query = new WP_Query( $args );
if ($featured_query->have_posts()) :
?>
<ul class="products">
<?php
echo "<h3>" . __("On Sale now") . "</h3>";
if ( $featured_query->have_posts() ) {
while ( $featured_query->have_posts() ) : $featured_query->the_post();
woocommerce_get_template_part( 'content', 'product' );
endwhile;
} else {
echo __( 'No products found' );
}
wp_reset_postdata();
?>
</ul><!--/.products-->
<?php endif; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment