I have a code:
$products_query_params = array(
'post_type' => 'product',
'product_cat' => 18,
);
return new WP_Query($products_query_params);
I need it to get products. But it works fine only if I write it directly in function.php - function $product->have_posts() returns true in this case in admin area.
But if I try to create a shortcode and display the same thing on the front end of the site, then $product->have_posts() returns false.
I think I need to add some parameter to $products_query_params, but I don't know which one.
$product
? What's your shortcode code?