I'm currently working on a widget which returns a single random featured property on a website but I'm having some trouble with my WP_Query arguments.
In the backend I have 2 checkbox meta fields "featured" and "hidden". I want to return a post which is has the "featured" field checked and the "hidden" field unchecked. My query is as follows:
$query_args = array( 'posts_per_page' => '1', 'orderby' => 'rand', 'post_type' => 'nc_property', 'meta_query' => array( array( 'key' => 'nc_featured', 'value' => 'on', 'compare' => '=' ), array( 'key' => 'nc_hidden', 'value' => 'on', 'compare' => '!=' ) ) );
The query returns a random featured property if I remove the second array so the problem lies with my
nc_hidden meta query but I'm not seeing it.
What's the correct way to check for an unchecked meta value?