I've seen plenty of samples of using meta_query to find if the value is between a range, where the range looks something like this:
$meta_query_args = [
'key' => "custom_field",
'value' => [ $_GET['start'], $_GET['end'] ],
'compare' => 'BETWEEN',
'type' => 'numeric',
];
I need to do kinda the opposite. My custom_field
has the range, and I can $_GET
the value I need to find if it's between that range or not. So if the value of custom_field
is 4-8
, and the value of $_GET['number']
is 5
, it should match. Basically, I need something like this:
$meta_query_args = [
'key' => "custom_field", // This may be a range like 4-8, or a number like 7
'value' => $_GET['number'], // This will be a single number, like 5
'compare' => 'BETWEEN', // I need to figure if 5 is within the range 4-8
'type' => 'numeric', // I will only deal with numbers.
];
However, as much as I've tried to find how to do this, I have failed. Any help would be appreciated.