How to query on custom taxonomy?

I’m trying to retrieve a list in descending order of posts which have a custom taxonomy called zoacres_property_price, so I wrote this query: $tax_id = get_queried_object()->term_id; global $wpdb; $query = “SELECT SQL_CALC_FOUND_ROWS $wpdb->posts.* p FROM $wpdb->posts INNER JOIN $wpdb->postmeta m ON (p.ID = m.object_id) WHERE ( $wpdb->term_relationships.term_taxonomy_id IN (%s) AND p.post_status = %s AND p.post_type…

Details