Comment dois-je utiliser posts_where au changement meta_value d'une chaîne à l'entier?
Question
Comment dois-je utiliser posts_where au changement meta_value d'une chaîne à l'entier?
La solution
Essayez ceci:
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;
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à wordpress.stackexchange