I have value like :-

if ( ! empty( $_GET['filter-area'] ) ) {
    $f = $_GET['filter-area'];
    preg_match_all('!\d+!', $f, $matches);
    foreach($matches as $key) {
        $first_val = $key[0];
        $second_val = $key[1];
    }
}

Now i need to search to get all date between this two values.

So, I tried this way, but it take one value.

if ( ! empty( $_GET['filter-area'] ) ) {
    $meta[] = array(
        'key'       => REALIA_PROPERTY_PREFIX . 'attributes_area',
        'value'     => $first_val,
        'compare'   => '>=',
        'type'      => 'NUMERIC',
    );
}

How can search by tow value

1
1

Multiple meta values can be compared with BETWEEN with an array value:

'meta_query' => array(
    array(
        'key'     => REALIA_PROPERTY_PREFIX .'attributes_area',
        'value'   => array( $first_val, $second_val ),
        'type'    => 'numeric',
        'compare' => 'BETWEEN',
    ), // inner array.
), // outer array.

You can see this in Developer Doc.

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *