Domanda

Come si usa posts_where ai cambiamenti meta_value da una stringa per intero?

È stato utile?

Soluzione

Prova questo:

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;

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

    return $where;
}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a wordpress.stackexchange
scroll top