[wp-trac] [WordPress Trac] #18158: Meta Query for posts with a meta key not set.
WordPress Trac
wp-trac at lists.automattic.com
Mon Jul 18 15:43:12 UTC 2011
#18158: Meta Query for posts with a meta key not set.
-------------------------+-----------------------------
Reporter: johnnyb | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Query | Version: 3.2.1
Severity: normal | Keywords:
-------------------------+-----------------------------
In the meta_query, we should be able to query for posts that don't have a
certain meta key at all. I suggest a syntax something like this:
{{{
...
meta_query => array(
array(
'key' => '_my_special_meta',
'compare' => 'NOT EXISTS'
)
)
...
}}}
Alternately this could be handled invisibly along the lines of:
{{{
...
meta_query => array(
array(
'key' => '_my_special_meta',
'value' => 'a_value_this_might_have',
'compare' => '!='
)
)
...
}}}
This could be done using a left join, and not some sort of special case
like above. Since it's a left join we may have to be careful that we
don't end up with a bunch of junk rows in the query, however.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/18158>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list