I tried the following code:
$posts = get_posts([
"post_type" => "CUSTOM_POST_TYPE",
"meta_query" => [
'relation' => 'AND',
[
'key' => 'longitude',
'value' => [-0.9895, 1.3125],
'compare' => 'BETWEEN',
"type" => "NUMERIC",
],
],
]);
When I remove "type" => "NUMERIC"
, I could reproduced your problem because the comparison is string based.
But when adding the type NUMERIC
, the MySQL request contains CAST(wp_postmeta.meta_value AS SIGNED) BETWEEN '-0.9895' AND '1.3125'
and the query returns the foreseen values.