Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

share|improve this question
add comment

1 Answer

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;
}
share|improve this answer
    
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 May 18 '11 at 10:34
    
why can't you use get_posts()? –  Brady May 18 '11 at 10:52
    
It's okay thank you –  Onita May 18 '11 at 11:58
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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