I would like to implement a search function where a user can enter an amount($amount) and based on that argument the search result needs to show all posts where $amount >= loan_min (meta key) AND $amount <= loan_max (meta key)
Let's suppose we have a post that has meta keys loan_min=100 and loan_max=500 then say entering 200 in search will show this post but if a user enters 50 or 550 in search then this post will not be showing in the result.
Here is how it is coded.
$meta_query = array(
'relation' => 'AND',
array(
'key' => 'minimum_loan_amount',
'value' => $loan_amount_requested,
'type' => 'numeric',
'compare' => '>='
),
array(
'key' => 'maximum_loan_amount',
'value' => $loan_amount_requested,
'type' => 'numeric',
'compare' => '<='
)
);