¿Cómo debo usar posts_where al cambio meta_value de una cadena de número entero?

wordpress.stackexchange https://wordpress.stackexchange.com/questions/3765

  •  16-10-2019
  •  | 
  •  

Pregunta

¿Cómo debo usar posts_where al cambio meta_value de una cadena de número entero?

¿Fue útil?

Solución

Prueba esto:

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;
}
Licenciado bajo: CC-BY-SA con atribución
scroll top