Sort posts according to a numeric value entered with ACF

I've tried a little bit of everything, but I still can't find the right solution.

I need to sort my posts according to a numeric value that is entered in each post. I'm using the following PHP code, but it's not working:

$args['meta_query'] = array(
    array(
        'key' = 'key',
        'type' = 'numeric',
    )
);

I also tried this code:

$args['meta_key'] = 'costo_attrazioni_ridotti_18_25';

Then of course I have these other values in the args as well:

$paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
$args=array(
        'post_type' = 'post',
        'post_status' = 'publish',
        'posts_per_page' = 10,
        'meta_key' = 'costo_attrazioni_ridotti_18_25',
        'order' = 'ASC',
        'orderby' = 'meta_value_num',
        'paged' = $paged,
);
$the_query = new WP_Query( $args );
if ($the_query-have_posts()):
    while ($the_query - have_posts()) : $the_query - the_post();?
        ...
    endwhile;
endif; unset($the_query); wp_reset_query();

How can I solve it? Thank you.

Topic loop Wordpress

Category Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.