按 ID 和价格订购 woocommerce 产品

Order by ID and Price woocommerce products

我正在使用自定义循环在页面上显示 woocommerce 产品,我需要按范围价格和产品 ID 订购,如下所示:

$args = array(
        'post_type' => 'product',
        'orderby'   => 'ID', 
        'order'     => 'desc', 
        'meta_query' => array( 'relation ' => 'AND',
            array(
               'key' => '_price',
               'value' => array( $minPrice, $maxPrice ),
               'type' => 'numeric',
               'compare' => 'BETWEEN',
               'order' => 'asc')
         )
       );

有人可以帮助我吗? 提前致谢

您可以查看此代码段。

$args = array(
        'post_status'   => 'publish',
        'post_type'     => 'product',
        'orderby'       => 'ID', 
        'order'         => 'asc', 
        'meta_query' => array(
            array(
                'key'      => '_price',
                'value' => array( $minPrice, $maxPrice ),
                'compare' => 'BETWEEN',
                'type' => 'NUMERIC'
            )
        )
    );

您可以从此类主题中获得更多想法