修改Woocommerce查询以仅显示具有销售价格的产品

时间:2015-09-18 00:41:15

标签: wordpress woocommerce

我一直在使用wordpress主题Enfold,其中包含短代码以显示Woocommerce产品的产品滑块。还包括编辑查询的过滤器:

$query = apply_filters('avia_product_slide_query', $query, $params);

默认查询变量如下所示:

Array(
[post_type] => product
[post_status] => publish
[ignore_sticky_posts] => 1
[paged] => 1
[offset] => 0
[post__not_in] => Array ( )
[posts_per_page] => 9
[orderby] => menu_order title
[order] => ASC
[meta_query] => Array (
    [0] => Array (
        [key] => _visibility
        [value] => Array (
            [0] => visible
            [1] => catalog
            )
        [compare] => IN
        )
    )
[tax_query] => Array (
    [0] => Array (
        [taxonomy] => product_cat
        [field] => id
        [terms] => Array (
            [0] => 13
            [1] => 64
            [2] => 65
            [3] => 15
            [4] => 67
            [5] => 66
            [6] => 23
            [7] => 73
            [8] => 75
            [9] => 10
            [10] => 52
            [11] => 53
            [12] => 50
            [13] => 51
            [14] => 12
            [15] => 48
            [16] => 11
            [17] => 44
            [18] => 14
            [19] => 55
            )
        [operator] => IN
        )
    )
)

有人知道在此查询中添加一些过滤器的方法,只显示已定义销售价格的产品吗?

1 个答案:

答案 0 :(得分:0)

最后我这样解决了:

$query['post__in'] = array_merge( array( 0 ), wc_get_product_ids_on_sale() );