All our Themes are Gutenberg Ready.

Okay so i was working on a project and had to list Woo-commerce featured products so i come up with this solution

$meta_query = WC()->query->get_meta_query();
$meta_query[] = array(
'key' => '_featured',
'value' => 'yes'
$args = array(
'post_type' => 'product',
'stock' => 1,
'showposts' => 6,
'orderby' => 'date',
'order' => 'DESC',
'meta_query' => $meta_query
$featured_query = new WP_Query( $args );

But it did not work completely fine for me and come up with this solution then,

$featured_query = new WP_Query( array(
'tax_query' => array(
'taxonomy' => 'product_visibility',
'field' => 'name',
'terms' => 'featured',
'operator' => 'IN'
) );

So if first does not work, try second one.

Write a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.