I also added this here for someone else having same issue.
If your meta values are numeric then you should use orderby meta_value_num
instead of meta_value
.
-
meta_value
– Note that ameta_key=keyname
must also be present in the query. Note also that the sorting will be alphabetical which is fine for strings (i.e. words), but can be unexpected for numbers (e.g. 1, 3, 34, 4, 56, 6, etc, rather than 1, 3, 4, 6, 34, 56 as you might naturally expect). Usemeta_value_num
instead for numeric values. -
meta_value_num
– Order by numeric meta value (available with Version 2.8). Also note that ameta_key=keyname
must also be present in the query. This value allows for numerical sorting as noted above inmeta_value
.
Related Posts:
- Meta_query compare operator explanation
- Exclude post ID from wp_query
- Can I force WP_Query to return no results?
- paginate_links() adds empty href to first page and previous link
- Get array of posts from the current archive page loop
- Custom query incorrectly returning everything [closed]
- Last post ordered by publish date using WP_Query on front page
- Meta Query with date and time on the same Day before given time
- In loop: posts have thumbnail AND other variables
- How to grab metabox value in wp_query meta_query key
- Add inline HTML to posts published within last 24hrs
- Add and in the header while looping over custom query in page template
- Stop all SQL_CALC_FOUND_ROWS wordpress queries
- Single page theme
- Pagination not working on static page
- WordPress pagination link always leads to home page
- Query posts with more than 20 comments
- Can certain (site-crashing) limitations on WP_Query in shortcode be overcome?
- Get array of current post term ID’s
- Including only current user’s posts in search
- Implementing an OR statement to wordpress wp_query
- How can i simulate “taxonomy__in” in query?
- Refine search results using WP_Query
- query_posts: how to show all ‘meta_value’ containing a specific word?
- How to show subcategories using loop?
- Minimize database queries to user tables?
- add_filter() depending on search term
- Get all products which have both product category
- How to make Meta Query case sensitive?
- Populate tax_query terms parameter with post term
- Orderby the sum of several numeric custom meta fields
- Fastest way of counting posts of a custom post type in a specific taxonomy term?
- wp_query ‘s’, search filter with pagination is not working
- Why is wp_query causing an uncaught error to is_user_logged_in() not defined?
- Modify wp-query and sort by post meta key
- WordPress query with items from more than one selfdefined taxonomy as `term` argument
- How to display an other custom post type in a different custom post type’s archive?
- Replacing raw database query to WP_Query
- How to alter local query, not main query [duplicate]
- WP CLI can’t delete plugin related table
- Inserting HTML to close and open divs in WP_Query loops
- Change query from cat id to slug or name?
- Query only the posts with a post format of “audio”
- Display Current Post’s Position in Custom Taxonomy
- Using Wp_Query without the loop?
- WP Query with multiple tags by get the tags
- infinite loop in wp_query using simple query
- Custom WP_Query id
- Woocommerce pagination and result count after custom loop
- Parent and child categories
- Set post number to single posts
- Easy way to write complex queries in wordpress
- Error with function in functions.php?
- I am having problem sorting custom post type using WP_Query
- difference between querying database and using the loop
- Query_vars support in Rest API
- How to do logical OR in terms in WP Query?
- Continue or break the while loop
- Custom query filter by ACF date custom field
- Child pages not affected by orderby
- Write WP Query that selects posts that are part of the same two categories
- Error in meta_query not get result
- Sorting posts by Multiple custom fields in defined order
- Custom wp_query – I’m getting ‘all’ post, not the specific post in the query
- Phpmyadmin – post editing
- Disable (or limit) queries when certain content (or data) is not needed (or showed)
- Query not sorting DESC
- Prioritising and Ordering Posts By Category Name Using A Custom Loop
- Filter products on category AND tag
- create a custom query for posts managed by Restrict Content Pro
- meta_query – check for multiple meta values in key which holds an array of values
- How to sort wordpress posts already selected by WP_QUERY
- How do I stop the same post showing multiple times in a archive?
- Searching for a specific month in a metadata saved as Timestamp (Wp_Query)
- WP_Query on custom key and value
- Set “editor” role to existing user
- how to get wp_query posts only first letter of alphabet A?
- How to mix two orderby-parameters into one ordered result
- Custom Post Type WP_Query with filters and search
- Merge wp-query and get_users
- Get posts by similar names and categories
- Query by meta value (add a dropdown of all values)
- WP Query issue for multiple values
- Calling a function with WP_Query only ever brings the first result
- get last child post by wp_query
- How To Query All Attachment Images Found In Post Galleries
- WordPress meta_query not working
- Create multiple sections for all categories and then queries all the posts for each of those categories
- Filter WP_Query output before it is accessed (pre_get_posts)?
- $wp_query when new WP_Query
- Divide WP_Query posts by date & post type
- Unable to pass variable
- WP Query get posts by specific author IDs if one of several logged in authors
- Edit WordPress loop, taxonomies, & filter
- WP query based on two meta queries
- WordPress website links redirect to homepage
- How to display posts from a specific term first then another posts from another terms using tax_query
- How to get all post_id and meta_value using meta_key in wp_postmeta table
- List categories using WP_Query
- WP Query – Show custom posts only if user contain some user meta