The featured product’s meta key is _featured
, but you are using featured
in your meta query. This will return no products, since the key doesn’t exist.
Also, as far as I know, the value of the key is yes
, so your arguments should be like this:
array(
'key' => '_featured',
'value' => 'yes',
)
Another note, is to use the proper way to get the shortcode’s attribute. You can do so by using shortcode_atts()
function. Here is the syntax for your case:
$atts = shortcode_atts(
array(
'limit' => '20',
'min' => '1'
'max' => '2'
),
$atts,
'product_price_filter_box'
);
$limit = intval($atts['limit']);
$min = intval($atts['min']);
$max = intval($atts['max']);
You might want to limit the maximum posts a user can get. This can be done by using the min()
function:
$limit = min(20, $limit);
And a final note. If you are using WP_Query
, you should use wp_reset_postdata();
instead of wp_reset_query();
, which is used after you use query_posts();
.