-1, 'return' => 'ids', 'status' => 'publish', 'post_type' => 'product', 'post__in' => $product_array_to_return, 'meta_query' => array( array( // Simple products type 'key' => '_sale_price', 'value' => 0, 'compare' => '>', 'type' => 'numeric' ), ), ) ); $product_array_to_return = wp_list_pluck($query->posts, 'ID'); //then return the query to wp $q->set( 'post__in', (array) $product_array_to_return); } function intersect2($arrayOne, $arrayTwo) { if($arrayOne != null && $arrayTwo != null){ if(!empty($arrayOne) && !empty($arrayTwo)){ $index = array_flip(array_filter($arrayOne)); $second = array_flip(array_filter($arrayTwo)); $x = array_intersect_key($index, $second); return array_flip($x); } else { return null; } } else { return null; } }