[wp-trac] [WordPress Trac] #18158: Meta Query for posts with a meta key not set (IS NULL).
WordPress Trac
wp-trac at lists.automattic.com
Tue Jan 17 21:38:46 UTC 2012
#18158: Meta Query for posts with a meta key not set (IS NULL).
-------------------------------------------------+-------------------------
Reporter: johnnyb | Owner:
Type: enhancement | georgestephanis
Priority: normal | Status: accepted
Component: Query | Milestone: Future
Severity: normal | Release
Keywords: dev-feedback needs-testing has- | Version: 3.2.1
patch | Resolution:
-------------------------------------------------+-------------------------
Comment (by georgestephanis):
Usage would basically be ...
----
$my_query = new WP_Query(
array(
'meta_query' => array(
array(
'key' => 'foo',
'compare' => 'not exists',
'value' => null,
),
)
)
);
----
'value' has to be included, or the meta_query gets skipped. However, it
is entirely ignored for EXISTS and NOT EXISTS meta_queries.
----
I would also recommend upgrading the db version and adding an index to the
`meta_key` column in `wp_postmeta` -- the idea had some support in IRC,
and it would make the join much more manageable in large sites.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/18158#comment:16>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list