Custom Field Sorting not working properly in WordPress

I am trying to sort loop by custom field but it is not working as it should be.
Like I have data 1200, 1300, 1400, 1500, 12500, 13500 normally it should sort like this but now I am seeing like this 1200, 12500, 1300, 13500, 1400, 1500. Please see my code and let me know where I am wrong.

Code:

 <?php
                        $args = array(
                                'post_status' => 'publish',
                                'post_type' => 'car',
                                'car_type' => 'suv',
                            'meta_key' => 'per_month_rent',
                            'orderby' => 'meta_value',
                            'order' => 'ASC',
                                'posts_per_page' => -1
                            // Several more arguments could go here. Last one without a comma.                                                  
                        );

                ?>
<div style="display: block;clear: both;">
                    <?php
                        // Query the posts:
                        $obituary_query = new WP_Query($args);
                        // Loop through the obituaries:
                        while ($obituary_query->have_posts()) : $obituary_query->the_post();
                            // Echo some markup
                        $image = wp_get_attachment_image_src(get_field('image'), 'best-seller-size');
                        $type=get_field('car_type');
                        $company=get_field('company_name');
                            include 'featured_list.php'; 
                        endwhile;
                        // Reset Post Data
                        wp_reset_postdata();
                    ?>

                </div>

Thanks in advance.

Read more here: Custom Field Sorting not working properly in WordPress

Leave a Reply

Your email address will not be published. Required fields are marked *