С этого вопроса WooCommerce: Display ONLY on-sale products in Shop Я попытался отобразить продукт с дисконтом. Но каждый раз, когда он отображает все продукты, это on_sale
. Я также пробовал _sale_price
Мета-ключ. Но я не могу понять, как я могу решить свою проблему. Мой выход проекта из моего кода WooCommerce: Показать ТОЛЬКО уцененный товар в списке
$args
Мои переменной
$args = array(
'post_type' => 'product',
'order' => 'ASC',
'meta_query' => array(
array(
'key' => '_sale_price',
'value' => 0,
'compare' => '>',
'type' => 'numeric'
)
)
);
Я также попытался ниже код. Но такой же результат
$args = array(
'post_type' => 'product',
'posts_per_page' => 8,
'meta_query' => array(
'relation' => 'OR',
array(// Simple products type
'key' => '_sale_price',
'value' => 0,
'compare' => '>',
'type' => 'numeric'
),
array(// Variable products type
'key' => '_min_variation_sale_price',
'value' => 0,
'compare' => '>',
'type' => 'numeric'
)
)
);