Make WordPress Core

Opened 5 years ago

Last modified 5 years ago

#15292 closed defect (bug)

It's not possible to check for "meta_value = 0" in wp_query->get_posts — at Initial Version

Reported by: hetjens Owned by:
Milestone: 3.2 Priority: normal
Severity: major Version: 3.0.1
Component: Query Keywords: has-patch commit
Focuses: Cc:


Because of the "empty" function of php it isn't possible to check for a meta_value = 0 in wp_query->get_posts.

My Case:
'meta_key' => '_menu_item_menu_item_parent',
'meta_value' => '0',

wp-includes/query.php Line 2307 is:
if ( ! empty($qmeta_value?) ) {

But empty says that String "0" is true (look here: http://ch2.php.net/empty )

So the query will return all posts that have a meta-field "_menu_item_menu_item_parent" and not only the posts with "_menu_item_menu_item_parent = 0" (which means, that it's an menu root item)

My solution is:

if (( ! empty($qmeta_value?) )
($qmeta_value? == '0')) {

but that's not very nice. Any better idea?


Change History (0)

Note: See TracTickets for help on using tickets.