WC_Product_Query not working with have_posts()
$query = new WC_Product_Query(array(
'limit' => 10,
'orderby' => 'date',
'order' => 'DESC'
));
$products = $query->get_products();
if (!empty($products)) {
foreach ($products as $product) {
echo get_permalink($product->get_id());
}
}
function have_post()
is member function of WordPress WP_Query
class - and WooCommerce WC_Product_Query
class is extending WC_Object_Query
class, not the WP_Query
- So this function cannot be called