Boohoo why did I start a bounty for that 😉 The answer is pretty simple – add ‘type’ => ‘numeric’ to the meta query.
array(5) {
["posts_per_page"]=>
int(6)
["orderby"]=>
array(2) {
["uss_product_price"]=>
string(4) "DESC"
["uss_product_weight"]=>
string(4) "DESC"
}
["meta_query"]=>
array(3) {
["relation"]=>
string(3) "AND"
["sortprimary_clause"]=>
array(3) {
["key"]=>
string(17) "uss_product_price"
["compare"]=>
string(6) "EXISTS"
["type"]=>
string(7) "numeric"
}
["sortsecondary_clause"]=>
array(2) {
["key"]=>
string(18) "uss_product_weight"
["compare"]=>
string(6) "EXISTS"
}
}
["paged"]=>
string(1) "1"
["post_type"]=>
string(7) "product"
}
Related Posts:
- Sorting: custom query with orderby meta_value_num THEN by title
- Custom WP_Query order by post_meta and (author) user_meta
- How to order a post type with meta_value_num and if meta_value_num does not exist then order by date
- Order WP Query posts by custom order calculated from post meta values
- Meta query with order by another custom field
- Order Posts by meta value AND published date
- pre_get_posts order by not working
- SQL: What is wrong with the following query (generated by WordPress WP_Query, ordering prices)
- How to orderby multiple meta fields if some fields are empty
- Help ordering Post loop by two meta values
- Order ascending is ignored in meta query?
- meta_value_num not ordering all items
- How to filter a query by multiple meta keys and order by other meta keys
- Advanced WP_Query with meta_query, orderby?
- Sort posts using multiple custom fields and menu_order in single query?
- What’s wrong with this meta query? (order by meta key, then title, doesn’t work)
- WordPress Query custom ordering by temporary variable
- Meta query orderby meta_value_num sorting by role first
- WP_User_Query Orderby Not Working
- Sorting with meta_query and multiple, optional meta keys
- WP Query. Ordering posts by another post types meta
- wp_query sorting – one specific meta_key value at last and then sort by create date
- Best way to Order Post in Home without a plugin
- Using orderby with 2 meta keys
- Sorting: custom query with orderby meta_value_num THEN by title
- WP_Query with several meta_query-statements and order by meta_value
- Meta_query compare operator explanation
- meta_query with meta values as serialize arrays
- Nested meta_query with multiple relation keys
- meta_query ‘compare’ => ‘IN’ not working
- Ignoring initial articles (like ‘a’, ‘an’ or ‘the’) when sorting queries?
- Use REGEXP in WP_Query meta_query key
- WP_Query orderby post__in remains ineffective in the Loop [closed]
- WP Query Args – Title or Meta Value
- WP_Query orderby date not working
- Meta query with string starting like pattern
- compare meta_query in get_posts arguments
- How to query posts based on lat-lng coordinate as post meta?
- how to show posts that are missing a meta_value
- Order by optional meta key?
- Set Alias for meta_query arguments in get_posts()
- Order by DESC, ASC in custom WP_Query
- WP_Query order by multiple meta keys & fields
- Display products from specific category in shop page
- Secondary Sort (fallback) for WP_Query
- How to Compare Two Meta Fields
- Changing the meta_query of the main query based on custom query_vars and using pre_get_posts
- Query Posts in a Predefined Order
- Does tax_query really beats meta_query in all situations?
- How to get order of posts?
- Order posts by ID in the given order
- WP_Query with checkbox meta_query
- ACF Relationship Field Search Filtering [closed]
- Add indexing to meta_value in wp_postmeta
- Is it possible to orderby multiple meta_keys when using meta_value_num?
- Sorting posts by custom date fields (non standard date format)
- Query WooCommerce orders where meta data does not exist
- Getting attachments by meta value
- Query Multiple Post types each with own meta query
- Execute a large WP_Query with many “AND” Meta_Queries?
- Query all posts where meta value is empty
- How to order posts tag by tag?
- WP_Query min and max values
- How do I order pages and categories by ID or name in the same query?
- ACF datepicker meta_query Compare Dates in m/d/Y g:i a – Not in Ymd Format
- WP_Query using meta_query with relation OR and orderby meta_value doesn’t work
- Using custom meta_query with relation not working as expected
- Perform query with meta_value date
- WP_Query ordered by custom field that is a date string?
- querying with custom meta field with meta_query
- Order by two meta keys
- multiple meta key but get server load is very high
- Meta Query with date and time on the same Day before given time
- A WP_Query that will look for posts after 2 weeks ago OR with a certain meta value
- How to grab metabox value in wp_query meta_query key
- WP_Query meta_query where meta value ends in space
- WP_Query sort by comment meta data
- Order by meta_value_num DESC and meta_value ASC on WP 4.0
- Trying to perform complex custom field query with order by set to field value
- Finding all results from database within 500 miles of the given latitude and longitude [closed]
- Nested query inside Logical operator OR not working in meta_query
- Is “orderby” in WP Meta Query conflicting with Meta Query?
- Query by meta_key and order by meta_value_num return orderby date
- What is an efficient way to query based on post_meta?
- Order posts by tags count?
- Merge 2 args in one WP_Query and order it by date
- WP_Query not working as expected for attachments and custom meta_query
- Orderby = none not working [duplicate]
- datetime picker, timestamps and meta queries
- How do I create my own nested meta_query using posts_where / posts_join?
- WP_query ‘orderby=none’ Problem
- Order posts by date and then by custom field
- WooCommerce: filter by parent product’s taxonomy and product variation’s meta data
- Revolution Slider Orderby Two Custom Fields
- Compare two meta-fields in a wp_query (where meta-field-A is larger than meta-field-B)
- Wp_query order by multiple custom fields?
- How can I create a WP_Query that returns posts where one meta_value
- Order posts ascending with number in title
- Meta Query querrying several post types based on ACF fields is broken after update to WP 4.1
- List taxonomy terms plus their latest post ordered by post date