1

I want to know if there is a way to DECIMAL (5,2) instead of DECIMAL in meta_query

1 Answer 1

3

Answer taken from here: meta_query: using BETWEEN with floats and/or casting to DECIMAL

add_filter('get_meta_sql','cast_decimal_precision');

function cast_decimal_precision( $array ) {

    $array['where'] = str_replace('DECIMAL','DECIMAL(5,2)',$array['where']);

    return $array;
}
2
  • I can't use "meta_query" like this : 'meta_query' => array( array( 'key' => 'color', 'value' => 'blue', 'compare' => 'NOT LIKE' ), array( 'key' => 'price', 'value' => array( 20, 100 ), 'type' => 'numeric', 'compare' => 'BETWEEN' ) ) with get_posts()
    – Onita
    Commented May 18, 2011 at 10:34
  • why can't you use get_posts()?
    – Scott
    Commented May 18, 2011 at 10:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.