Problem with a query in custom posts

Like the commentor say, couldn’t you use WP_Query for this? $results = new WP_Query(array( ‘post_type’ => ‘products’, ‘meta_query’ => array( ‘key’ => ‘availability’, ‘value’ => $MyDate_a, ‘compare’ => ‘=’ ), ‘order’ => ‘DESC’, ‘orderby’ => ‘meta_value’ ));