我一直在使用包含短代码的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
)
)
)
有没有人知道一种方法来添加一些过滤器到这个查询只显示已定义销售价格的产品?
最后我是这样解决的:
$query['post__in'] = array_merge( array( 0 ), wc_get_product_ids_on_sale() );