If you look at the 50+ similar questions on Stack Overflow you’ll see that you can only do so with considerable difficulty, and you won’t have a very efficient query once you get it working. MySQL just isn’t built to sort that way, and honestly the sort pattern you want is really very peculiar anyway. It isn’t a normal sort by any standard.
And that is pure SQL. WP_Query
is capable of much less finesse– without the application of filters anyway.
Your best approach is going to be to normalize your data on insert, saving the numeric portion to one key and the rest elsewhere. Or force the number to the front followed by some marker like a comma that will let you juggle it back to the end on display.
Related Posts:
- How to get all term meta for a taxonomy – getting term_meta for taxonomy
- Job of meta_key meta_value fields in database tables
- order by multiple meta_keys?
- How to get the total number of meta_values based on a custom post type?
- WP_POSTMETA – What do these values mean inside the data structure?
- How can I convert postmeta from unserialized to serialized?
- Sort custom posts in archive by multiple values: date AND meta key
- why after saving meta value it’s saving all the values the one that i clicked?
- Is it safe to add a new field to meta_value field?
- Get posts ordered by meta data
- Display current ranking of post as a number in post title
- I can not display meta value in extras.php and template-tags.php
- Count Post and Page Views based on meta_value Using Shortcode in Dashboard Widget
- Negative meta_query if storing multiple post_meta values with shared meta_key
- Sorting my posts on homepage my specific value in post_meta table
- if get_post_meta function returns empty – Do Not Display HTML
- How to get the total of two meta values from different meta keys?
- How to save a meta_value as a numeric value after I retrieve it via update_post_meta?
- How to update/add child posts meta whenever the parent post meta is updated?
- Multiple meta key and value search in the query
- How to sort by meta value num, but ignore zero value?
- Re-order posts inside tax query
- How do I retrieve the slug of the current page?
- How to extract data from a post meta serialized array?
- How to save an array with one metakey in postmeta?
- WordPress is stripping escape backslashes from JSON strings in post_meta
- What’s the point of get_post_meta’s $single param?
- Lack of composite indexes for meta tables
- Content hooks vs User hooks
- Save both current and new version of post meta
- Compare 3 custom fields and sort by oldest
- get_post_meta – get a single value
- get_post_meta / update_post_meta array
- How do I access post meta data when publishing a new post in Gutenberg?
- Triple meta_key on custom SELECT query
- update_post_meta not adding anything.(Nor add_post_meta)
- Identifying Importer Posts
- How metadata API works?
- How to sanitize post meta field value?
- Post IDs missing on delete_postmeta action hook
- How trigger to save post when updating post meta
- Create a Metabox that behaves Like a Taxonomy Box
- Views count with time limit per IP
- echo image caption
- get_*_meta doesn’t always return an array
- How can I sort posts by the date and a custom meta field?
- Generate multiple goo.gl shortlinks for qtranslate bilingual blog
- How to orderby multiple meta fields if some fields are empty
- Saving repeated option values when querying in Published, draft and all
- add_post_meta adds meta to one more different post
- Custom query, multiple custom keys
- Trying to get property of non-object error using get_post_meta()
- Ordering posts by custom field named “date” in backend
- How can I change the tag contents of individual WordPress posts?
- get_post_meta producing white screen of death
- update_post_meta not working in plugin
- Look up all posts by status or meta value – performance difference
- Can A Post Meta Field Store multiple values that are not in an array?
- esc_attr on get_post_meta [closed]
- Delete posts based on post meta data
- How is the author’s name given a different color?
- How does WordPress treats attachments metadata in post content?
- URL to Post Meta [closed]
- Retrieving post meta array (attachment)
- Filtering by multiple conditions in the loop
- Why is variable that get_post_meta stored in empty?
- Stop `update_post_meta` from working each time page refreshes?
- Displaying values from related field – if empty shows current post type’s link and title
- get_post_meta inside echo [closed]
- WordPress postmeta: Store data as an array or single item?
- Display Post Meta in Header
- Array of user ids to list of user names
- Conditional For get_the_author_meta
- Custom fields or something else
- I want to Add Feedburner Right After Meta Details
- Custom column on CPT not showing correct value when meta data not set
- How to access post meta on the first time a post is published
- Removing Malware
- I Can’t get the post_tag name from term_id using wp_set_object_terms
- How to query post with meta?
- why is my postmeta table is so heavy
- update_post_meta() throws Uncaught error: Cannot create duplicate attribute
- Using a comma instead of a pipe to separate metadata
- show user based on user_meta
- Meta keys won’t add using wp_insert_post
- How Can I extract Image urls from post meta
- Plugin Shortcode value in post
- Retrieve posts from meta key
- Assign postmeta in bulk
- How do i get value from wp_postmeta?
- Twenty Twelve entry meta data – change and move
- How can I prevent the post_modified column in wp_posts from being updated?
- Sorting meta box values by start- and enddate and all dates in between
- Use an id on a button to update_post_meta in post
- get_post_meta image width for lazy load
- Custom Fields help
- WP-API : post_meta not updated… but have another entry
- Parse error thrown by get_post_meta [closed]
- How to get all the related ids without array?
- Remove action of an external plugin after checking if custom post meta is set