You could also use the posts_orderby
filter:
function wpse155827_posts_orderby_price( $orderby ) {
return str_replace( 'wp_postmeta.meta_value', 'substr(wp_postmeta.meta_value, 1)', $orderby );
}
add_filter( 'posts_orderby', 'wpse155827_posts_orderby_price' );
$theQuery = new WP_Query( array(
'orderby' => 'meta_value_num',
'meta_key' => 'price',
'order' => 'ASC',
'suppress_filters' => false,
) );
remove_filter( 'posts_orderby', 'wpse155827_posts_orderby_price' );
Related Posts:
- Sorting: custom query with orderby meta_value_num THEN by title
- Changing the meta_query of the main query based on custom query_vars and using pre_get_posts
- Sort posts by category name and title
- Custom WP_Query order by post_meta and (author) user_meta
- Query WooCommerce orders where meta data does not exist
- Perform query with meta_value date
- Finding all results from database within 500 miles of the given latitude and longitude [closed]
- Query Set Order By Author
- How to implement time filter to show random post 1 month for one category and 3 months for other categories
- Meta query with order by another custom field
- Meta Query for specific months
- Optional Meta Query
- Overwrite YoastSEO meta-tags with another page’s [closed]
- How to orderby multiple meta fields if some fields are empty
- WP_query sorting can’t sort danish letters (æ, ø, å)
- Help ordering Post loop by two meta values
- Meta Query relation “AND” then set array accordingly
- Sort WordPress Posts Meta value by Week not Day
- How to set up hierarchical relationships without using plugins / meta query
- Sorting search results with custom dropdown
- Is it possible to retrieve posts depending on meta_key LIKE condition? [duplicate]
- Why doesn’t my WP Meta Query return any results?
- WP_Query meta compare must include ALL array values
- meta_query where the meta value is not the post title
- Query multiple post types, but different order for each
- Order (by ASC) posts with meta_key so posts without values are last
- Woocommerce Get Orders By Meta Value
- How to do WP_User_Query for Nested Array value Inside Nested Array field
- Move some posts to end of sort order, even if there is a sort in the wp_Query already
- Meta query orderby meta_value_num sorting by role first
- Query against multiple locations within single custom post type post
- Strange results from WP_Query
- WP Query. Ordering posts by another post types meta
- Slow wp_posts and wp_postmeta query using Advance Custom Fields
- Query by meta value (add a dropdown of all values)
- Meta query doesn’t remove placeholder escape before query
- What is the best way to reset a search on a meta_key / meta_value?
- Ignoring ‘a’ when sorting posts
- How can I modify standard search query to include also ACF custom fields values?
- Filter posts/pages by user_role array
- Sorting: custom query with orderby meta_value_num THEN by title
- Sort Posts with custom meta key by default which is currently set as optional
- Get WP_Query query after execution?
- Use meta query only 3 or more results?
- Use value from meta key array for use in WP_Query
- How to use meta_query to retrieve posts from multiple custom post type
- query loop “inherit query from template” prevents setting sort order
- When should you use WP_Query vs query_posts() vs get_posts()?
- Meta_query compare operator explanation
- meta_query with meta values as serialize arrays
- Nested meta_query with multiple relation keys
- order by numeric value for meta value
- meta_query ‘compare’ => ‘IN’ not working
- Wp get all the sub pages of the parent using wp query
- Ignoring initial articles (like ‘a’, ‘an’ or ‘the’) when sorting queries?
- Return only Count from a wp_query request?
- Use REGEXP in WP_Query meta_query key
- WP Query Args – Title or Meta Value
- How to query for most viewed posts and show top 5
- 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?
- WP_Query vs get_posts
- how to show posts that are missing a meta_value
- Set Alias for meta_query arguments in get_posts()
- WP_Comment_Query pagination, delving into the unknown
- Random sort within an already sorted query
- Usage of the new “posts_clauses” filter in WordPress 3.1?
- Display products from specific category in shop page
- Make a WP Query search match exactly the search term
- WP_Query: query posts by ids from array?
- How to Compare Two Meta Fields
- Meta Query with AND & OR?
- Does tax_query really beats meta_query in all situations?
- How to get order of posts?
- WP_Query with checkbox meta_query
- ACF Relationship Field Search Filtering [closed]
- How to uniquely identify queries?
- What is the most efficient way of querying posts based on visits and date for current day?
- Add indexing to meta_value in wp_postmeta
- Is it possible to orderby multiple meta_keys when using meta_value_num?
- How to get Page/Post Gallery attachment images in order they are set in backend using WP_Query()?
- WP Query orderby meta key natural sort?
- Getting attachments by meta value
- Query Multiple Post types each with own meta query
- WP_Query for WooCommerce Products
- pre_get_posts with get_posts
- Execute a large WP_Query with many “AND” Meta_Queries?
- Query all posts where meta value is empty
- author.php with ACF and CPTs
- WP_Query min and max values
- Query Custom Meta Value with Increment
- When should you use wp_reset_postdata vs wp_reset_query?
- Loop through all tags & output posts in alphabetical list
- Get posts by meta data OR title
- 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
- Identify which loop you are hooking into; primary or secondary?
- WP_Query ordered by custom field that is a date string?