WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question

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


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

Your Answer


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.