Compare meta_query decimals not working right

The issue is that the default comparison for meta_query is a CHAR comparison, so the order that the numbers would be in by default would be 1, 10, 2, 3, 4, 5, 6, 7, 8, 9, a, etc. To resolve this you need to modify your meta_query as follows:

'meta_query' => array(
    array(
        'key'     => 'rating',
        'value'   => 8,
        'compare' => '>=',
        'type'    => 'NUMERIC'
    )
),

Leave a Comment