[wp-trac] [WordPress Trac] #20079: wp_query excludes posts without custom field from search
WordPress Trac
wp-trac at lists.automattic.com
Mon Feb 20 09:18:54 UTC 2012
#20079: wp_query excludes posts without custom field from search
--------------------------+----------------------
Reporter: gdah.ayoub | Owner:
Type: defect (bug) | Status: closed
Priority: normal | Milestone:
Component: Query | Version: 3.3.1
Severity: normal | Resolution: invalid
Keywords: |
--------------------------+----------------------
Changes (by scribu):
* status: new => closed
* resolution: => invalid
* milestone: Awaiting Review =>
Comment:
Yes, that's expected behavior. To also get posts that don't have the
custom field at all, you'll have to write:
{{{
'meta_query' => array(
'relation' => 'OR',
array(
'key' => $prefix.'statut',
'value' => 'Non commercialisé',
'compare' => '!=',
'type' => 'CHAR',
),
array(
'key' => $prefix.'statut',
'compare' => 'NOT EXISTS',
),
)
}}}
Note that 'NOT EXISTS' is not implemented yet: #18158
--
Ticket URL: <http://core.trac.wordpress.org/ticket/20079#comment:2>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list