In order to deliver the amount variable to be less than 25000 you need to check the query with the operator called <=
but you have tested it with >=
in your query.
Note: There are several comparison operators available
= equals
!= does not equal
> greater than
>= greater than or equal to
< less than
<= less than or equal to
But in your query you have misjudged the query and used. You have to use
<=
rather you have used>=
<=
– Less than or Equal to>=
– Greater than or Equal to
Usage of relation is appreciated in the Meta Query since without specifying the relation you are not supposed to mix the array of parameters that is given to the query for execution
$args = array(
'post_type' => 'loan-offers',
'meta_query' => array(
relation => 'AND', // This can be AND / OR depending on your choice
array(
'key' => 'amount',
'value' => $amount,
'compare' => '<='
),
array(
'key' => 'time',
'value' => $months,
'compare' => '>='
)
));
LIKE
and NOT LIKE
are SQL operators
that let you add in wild-card symbols, so you could have a meta query that looks like this:
array(
'key' => 'name',
'value' => 'Pat',
'compare' => 'LIKE'
)
Get Posts Within a Given Range of Numeric Meta Values
// the loan-offers is more than 10000 and less than 25000
$rd_args = array(
'post_type' => 'loan-offers',
'meta_query' => array(
array(
'key' => 'amount',
'value' => array( 10000, 25000 ),
'type' => 'numeric',
'compare' => 'BETWEEN'
)
)
);
$rd_query = new WP_Query( $rd_args );
You can use BETWEEN operator for getting the output as required by you.