Support

Account

Home Forums General Issues Meta Query Using true/false OR Not Exists

Helping

Meta Query Using true/false OR Not Exists

  • I’ve added a true/false field on some custom post types that already exist. I would now like to query posts based on whether the field is false OR if the field doesn’t exist. This way, I don’t have to go back in and re-save all of the old posts that were created BEFORE I created the true/false field.

    However, I cannot get this to work. Here’s my code:

    'meta_query'     => array(
    	'relation'   => 'OR',
    	array(
    		'meta_key'       => 'management',
    		'meta_compare'   => 'NOT EXISTS'
    	),
    	array(
    		'meta_key'       => 'management',
    		'meta_value'     => false,
    		'meta_compare'   => '=',
    	),
    ),
  • Use 1 and 0 … should work.

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Meta Query Using true/false OR Not Exists’ is closed to new replies.