You want natural order sorting,
Example;
$val = array(5.1, 5.11, 5.12, 5.2, 5.21);
natsort($val);
foreach ($val as $key => $val) {
echo $val."<br>";
}
Produces:
5.1
5.2
5.11
5.12
5.21
Where as;
$val = array(5.1, 5.11, 5.12, 5.2, 5.21);
asort($val);
foreach ($val as $key => $val) {
echo $val."<br>";
}
Produces:
5.1
5.11
5.12
5.2
5.21
Solution
$loop = new WP_Query(array(
'factsheet_category' => $term->slug,
'orderby' => 'meta_value meta_value_num', //addition of meta_value before meta_value_num
'meta_key' => 'factsheet_id',
'order' => 'ASC'
));
Related Posts:
- Change order of posts
- filter custom field values $min $max
- WP Query – Is this correct?
- Meta_query ‘compare’ => ‘LIKE’ not working?
- Checking if field is set before comparing with meta_query in query_posts?
- Filter Query Post by Custom Fields(by date)
- Using meta_query, how can i filter by a custom field and order by another one?
- Query Posts or Get Posts by custom fields, possible?
- ORDER BY custom field value
- Add custom fields to search
- SELECT max(meta_value) FROM wp_postmeta WHERE meta_key=’price’… stops working when value is over 999
- Matching Serialized Arrays with meta_query
- Meta Query with AND & OR?
- Filter archive.php by custom meta
- Trying to perform complex custom field query with order by set to field value
- Order posts by custom field and if custom field is empty return remaining posts
- WordPress Search Custom Meta Field Only
- Compare meta_query decimals not working right
- Ordering posts by anniversary using only day and month
- Loop through two different sets of custom fields
- Query on custom field count?
- Slow meta query with multi meta keys
- How to use query_posts() with a date filter on a custom field?
- How can I query on the year part of a complete date in a custom field?
- How can I combine meta_query queries?
- Difference between ‘LIKE’ and ‘IN’ in meta queries
- Sorting posts by multiple values, combined
- WP_Query display next custom post from today’s date
- Can ordering post list by meta_value cause performance issue?
- Order by value in serialized custom field
- Which is best in the following scenario : post_meta vs custom table vs parent/child posts
- WP_Meta_Query causing long-running MySQL queries
- Author Page Custom Query WHERE author OR [post meta value] OR [post meta value]
- meta query not showing any results?
- Sorting posts by custom fields in meta_query
- meta_query for a string inside a meta field containing a comma-separated list
- how can i use custom field in query post
- using multiple meta_key and meta_value in query_posts
- Complex WP_User_Query call fails on production server
- Query post order by post and desc not working
- Orderby custom field meta value ASC and then by date DESC
- Order query by meta_value with multiple custom fields
- How make a custom search on backend in WordPress without plugin?
- How to add a new meta key and assign timestamp to posts
- Show 1 post and after a specific date show the next one
- Get content from pages with same meta_key from Database
- WP 3.1 meta_query for multiple custom field values
- How to select posts from multiple categories and metavalues?
- meta_compare seems to be treating values as strings instead of integers as expected
- Fetch Record based on meta key dates
- How do I have WP_Query match posts based on search parameter OR meta fields? (rather than search parameters AND meta fields)?
- Get posts with same meta value as current post
- Alter main archive, to show posts with meta as last
- Meta Query And/Or
- Use meta_query to get title of associated post
- Meta query with multiple custom fields for archives page ordering problem
- Ordering posts by custom field named “date” in backend
- query posts custom field calculation value
- Get Data From wp_sitemeta for Multisite network
- Unique meta_key with array value vs repeated meta_key with single values
- get posts where a custom field contains a text
- How can I do a variable for meta_query?
- Query_posts with custom field meta value
- Avoiding ACF get_field and returning to core WordPress function
- Unable to get specific value from post meta
- comment meta_query for keys that aren’t yet set
- Query post by date (stored custom field meta as yyyymmdd) and differentiate across 12 months
- change order of images attached to post
- Custom search SQL Query to add custom field in result
- tax query between operator like
- How can I change the publish date based on a custom field?
- Best way to sort estates and query them (for rent? yes/no. contains office space? yes/no)?
- Is it possible to compare the current time with a custom “start” and “end date
- Get author total post votes from post meta
- Problem with writting correctly a query posts args in WordPress
- How can I modify my meta_query to work with prices that are stored in the database that contain dollar signs and commas?
- Need to search a custom field (ingredients, one long string per post), but want it to allow phrases/non-exact matches
- Making WP_Query limit results by date before today where date is a meta_query
- multiple meta_query and orderby question
- get posts based on non-single metadata
- How do i create a custom post query when the meta value is an array?
- Woocommerce products search with custom fields
- How to save multiple values with same meta_key, each value linked to another tag id
- How to improve my non-unique metadata MySQL entries?
- Filtering posts by ACF meta query
- Why does my numeric meta query work only on one meta key and not the other?
- meta_query to check all custom fields
- Query multiple meta values at the same time :
- Create Shortcode shows only posts with custom_field meta
- query_posts -> get page_id from custom field
- meta_query ‘compare’ => ‘!=’ not working
- Create custom query for search?
- Filter query based on date in custom field
- Query Posts Via WordPress URL
- Meta_query not filtering posts
- Filtering posts by WORD in custom field
- Display agents (custom post type) alphabetically, except one who always shows last
- How do delete a meta key?
- Dynamic background image used in css after selector
- WP Query Args – search by meta_key or title