在WP_Query对象WordPress中更改post index

时间:2015-09-02 11:36:27

标签: php wordpress

我在WordPress博客上使用WooCommerce。我想按价格对产品进行分类,并订购ASC(100,200,400,500,...),但这些价格设置为零或空(未设置)的产品将移至列表的末尾(将显示在最后一页的分页)。

我尝试使用the_posts过滤器编辑查询,但它不起作用。如果有人可以帮助我,我会非常感谢你。

$args = array(
    'posts_per_page' => 16,
    'post_type' => 'product',
    'meta_key' => '_price',
    'orderby' => 'meta_value_num',
    'order' => 'ASC'
);
$query = new WP_Query($args);

抱歉我的英语不好。

0 个答案:

没有答案