Sign up ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

How should I use posts_where to change meta_value from a string to integer?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Try this:

add_filter('posts_where', 'unquote_numeric_meta_value', 10, 2);

function unquote_numeric_meta_value($where, $args) {

    $value = isset($args->query_vars['meta_value']) ? $args->query_vars['meta_value'] : false;

        $where = str_replace("'{$value}'", $value, $where);

    return $where;
share|improve this answer
Thanks! That seems to work! – jnthnclrk Nov 8 '10 at 12:02

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.