2

I'm trying to use meta_query parmater to get posts with values between two values, the problem is it doesn't work for all the numbers.

This is work:

$array[] = array(
    'key' => 'd_weight',
    'value' => array(0,0.5),
    'compare' => 'BETWEEN',
    'type' => 'NUMERIC'
);

But for some reason this doesn't work:

$array[] = array(
    'key' => 'd_weight',
    'value' => array(0.1,0.5),
    'compare' => 'BETWEEN',
    'type' => 'NUMERIC'
);

The problem only occurs with numbers less than 1, on bigger number there is no problem...

Thanks for the help.

4

2 に答える 2

4

10 進数の場合は、'NUMERIC' の代わりに 'DECIMAL' を使用する必要があります。

$array[] = array(
    'key' => 'd_weight',
    'value' => array(0.1,0.5),
    'compare' => 'BETWEEN',
    'type' => 'DECIMAL'
);
于 2013-01-25T13:59:39.690 に答える