I'm trying to show all rental properties, first by all properties that have not been rented, and then by all properties that are currently rented. There is a custom post type 'rent' with custom post meta for price rented (_price_rented) which is a checkbox (returns either true or false... true if it HAS been rented). I need to change the query to show all properties with the available (non-rented) properties appearing first and then the rented properties appearing.
Here is my query:
$ts_properties = new WP_Query( array( 'post_type' => 'rent', 'paged' => $paged, 'posts_per_page' => -1, 'meta_key' => '_price_rented', 'orderby' => 'meta_value', 'order' => 'DESC', 'meta_query' => array( array( 'key' => '_price_rented', 'value' => false, 'type' => 'BOOLEAN', ), ) ) );
For some reason this query shows all properties that HAVE been rented. When I switch the value from 'false' to 'true' in the meta_query it doesn't show any properties.
So, then I thought, the return value is either false (for properties that ARE rented) or NULL (for properties that are NOT rented), but am not sure how to query for a NULL result (not false), I added a 'compare' argument to the meta_query and set the value to '!=' but that didn't work either.
EDIT: var_dump returns the following for an available, non-rented apartment:
string(0) "" and for a non available, rented, apartment: