我编写了一个函数,用于按价格范围获取产品。所有的工作,但现在我需要添加一个额外的元密钥,这将是50-100和功能,但代码不会返回任何产品。此代码有什么问题?
function product_price_filter_box($attr) {
$limit = intval($attr[\'limit\']);
$min = intval($attr[\'min\']);
$max = intval($attr[\'max\']);
$query = array(
\'post_status\' => \'publish\',
\'post_type\' => \'product\',
\'posts_per_page\' => $limit,
\'meta_query\' => array(
\'relation\' => \'AND\',
array(
\'key\' => \'_price\',
\'value\' => array($min, $max),
\'compare\' => \'BETWEEN\',
\'type\' => \'NUMERIC\'
),
array(
\'key\' => \'featured\',
\'value\' => \'1\',
\'compare\' => \'=\',
),
)
);
$wpquery = new WP_Query($query);
while ( $wpquery->have_posts() ) : $wpquery->the_post(); global $product;
wc_get_template_part( \'content\', \'product\' );
endwhile;
wp_reset_query();
}
add_shortcode( \'product_price_filter_box\', \'product_price_filter_box\' );