I realize that maybe this could be an already submitted question and I searched for it, but couldn't find it.
I've got the following simple meta query:
if (!is_admin() && is_post_type_archive('custom_post') && $query->is_main_query()) {
$meta_query = array(
array(
'key' => 'is_hidden',
'value' => 'on',
'compare' => '!='
),
);
$query->set('meta_query', $meta_query);
$query->set('posts_per_page', -1);
}
What I expect is to get all the "custom_post" posts in the relative Archive page that DOESN'T have the "is_hidden" checkbox active (so an ''/empty value instead of 'on' -> this is the value I get from CMB2 custom field checkbox). But it doesn't work, as the result is no posts at all.
While if I set the 'compare' to "equal" ('=') it works – meaning: I get only all the posts with the "is_hidden" checkbox set to 'on'.
Maybe I'm missing something...
is_hidden
set toon
have another value? Or just no value at all?