[wp-hackers] meta_query using the same key twice.

Dion Hulse (dd32) wordpress at dd32.id.au
Fri Jun 3 02:22:02 UTC 2011


That should work, By default it's AND'd together from memory.
However, It will cause a extra join per meta specification (ie. -1 will be 1
join, >= time will be another join).

Hate to say this, But sometimes the best way is to simply write a testcase,
just instantiate a new WP_Query, pass the args, and check WP_Query->request
(I think) for the SQL generated (or just dump the entire object), You should
be able to see pretty easily if the generated SQL has included both
conditions.

On 3 June 2011 10:51, Daniel Cameron <dan at sproutventure.com> wrote:

> Is something like this possible?
> $args=array(
> 'post_type' =>'special_stuff',
>  'post_status' => 'publish',
> 'meta_query' => array(
>  array(
> 'key' => '_expiration_date',
> 'value' => '-1',
>  'compare' => '='
> ),
> array(
>  'key' => '_expiration_date',
> 'value' => current_time('timestamp'),
>  'compare' => '>='
> )
> )
>  );
>
> Seems like this should have been covered already but I can't find anything.
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list