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
- Update post meta array – add new, single value
- How do I retrieve the slug of the current page?
- Most efficient way to get posts with postmeta
- How to only display posts whose meta_value field is not empty?
- Get posts by meta value
- Explanation of update_post_(meta/term)_cache
- 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
- How can I get the post ID from a WP_Query loop?
- Check if Post Title exists, Insert post if doesn’t, Add Incremental # to Meta if does
- How to update_post_meta value as array
- Adding meta tag without plugin
- What’s the point of get_post_meta’s $single param?
- What is the different between an attachment in wp_posts and an attachment in wp_postmeta?
- Order by optional meta key?
- How to edit a post meta data in a Gutenberg Block?
- Sanitizing integer input for update_post_meta
- post formats – how to switch meta boxes when changing format?
- Execute action after post is saved with all related post_meta records (data)
- Lack of composite indexes for meta tables
- Get a single post by a unique meta value
- if get_post_meta is empty do something
- How we get_post_meta without post id
- How get post id from meta value
- What is the code to get the download link for a product in WooCommerce?
- Safe to delete blank postmeta?
- Sort Order for a Custom Query in a Post Type Archive Not Working
- Dealing with Many Meta Values, 30+
- advanced custom fields update_field for field type: Taxonomy
- update_post_meta not saving when value is zero
- Content hooks vs User hooks
- Meta compare with date (stored as string) not working
- Ordering posts having multiple post-meta date fields
- Trying to get custom post meta through Jetpack JSON API [closed]
- How to update/insert custom field(post meta) data with wordpress REST API?
- Restrict post edit/delete based on user ID and custom field
- get_post_meta returning empty string when data shows in the database
- publish_post action hook doesn’t give post_meta_data
- Remove WordPress.org Meta link
- Remove post meta keys
- How to access the post meta of a post that has just been published?
- Why time functions show invalid time zone when using ‘c’ time format?
- Why is get_post_meta returning an array when I specify it as single?
- How to update/delete array in post meta value?
- Adding an assisting editor box to Post page
- Meta query interfering with orderby relevance
- delete unused postmeta
- Should I sanitize custom post meta if it is going to be escaped later?
- Add post meta based on another post meta value before publish post
- How do I retrieve multi-dimensional arrays from the wp_postmeta table, & display on a website?
- Front-end update_post_meta snippet displays white screen?
- Query between two meta values?
- Save both current and new version of post meta
- Get Advanced Custom Fields values before saving [closed]
- Give extra post-meta to RSS feeds
- How to get meta value in wp_attachment_metadata
- Compare 3 custom fields and sort by oldest
- Order by custom field date with ASC order
- WP REST API “rest_no_route” when trying to update meta
- Clean up output added via wp_head()
- List posts under meta_value heading
- WordPress Admin Panel search posts with custom post meta values along with title
- Why am I getting an infinite loop with have_posts?
- get_post_meta – get a single value
- delete value 0 in post meta [closed]
- Can I safely delete a record, manually, in the wp postmeta table?
- How to store post meta in an array?
- What action hook updates post meta?
- Can’t translate the post meta data (Date) in another language
- get_post_meta / update_post_meta array
- Ordering posts by anniversary using only day and month
- adding a URL to a post meta
- How to break meta values into different items and avoid duplicates?
- Exclude a category from the filed under list
- Short of raw SQL, can I query for multiple attachment metadata that have a given array key?
- How do I access post meta data when publishing a new post in Gutenberg?
- update_post_meta() not working when used with WordPress action