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
- Display products from specific category in shop page
- Meta Query with AND & OR?
- How to uniquely identify queries?
- How to make an activities stream mixing posts and comments?
- Order by meta_value_num DESC and meta_value ASC on WP 4.0
- How to query for a week using key => value WP_Query argument notation?
- Query by meta_key and order by meta_value_num return orderby date
- WordPress altering my custom query, How to fix it?
- Comparing timestamps in meta query doesn’t work
- Order by meta_key in custom post type doesn’t affect the query
- How to create/modfiy WP_Query to search in post title OR custom field?
- How to detect custom query inside `posts_where` hook?
- Is temporarily overwriting $wp_query a bad idea?
- How to output different posts per page?
- Multiple meta queries but arrange by specific meta value order
- Order Posts by meta value AND published date
- Pass array of taxonomy terms to wp_query
- What format does the meta_query TIME type require?
- Meta Query Array Error 500
- Custom Query num_rows returns wrong amount
- Fetch Record based on meta key dates
- WP_Query with ‘rand’, but equal number of posts from the taxonomy terms given
- meta_query not working as expected
- Query posts with “non set” meta value
- Ordering a mysql style datetime stamp with meta_query
- 2 wordpress loops showing 1 post from same post type – how to avoid showing the same post?
- Wp_query with 2 meta keys and array of meta values
- meta_query: check if number exists
- Event with multiple dates, display events chronologically
- Query where ANDing slug values not working
- How to use a dropdown to filter posts by custom field
- How to SQL query posts IDs by categories AND authors?
- WP Query / Meta Query [duplicate]
- How to add date_query to meta_query array
- Order by the first array within a meta_query
- Combine query in WP_User_Query()
- Multiple nested meta queries
- WordPress Query custom ordering by temporary variable
- Comparing Meta Field date in WPQuery using Meta_Query?
- How to create better WP_Query to look for date time which is anywhere between two meta values?
- How to get_comments() ordered by date and parent?
- compare for multiple meta values for same key in wp_query
- datetime picker, timestamps and meta queries
- WP_Query with meta_query won’t orderby
- Adding Category in WP_Query Not Working
- Fetch only categorized posts
- Wrap group of wp query posts to parent div by date/year
- Extending WP Query: Custom geolocation meta values work, but tax_query breaks
- Looking for a way to exclude frontpage and nav menu from query filter
- Showing posts from 4 categories along with all latest posts
- Creating Custom Query
- Get posts by meta value except one post [closed]
- WordPress extremely slow when using get_posts with multiple meta_query relations
- Search results stuck on page 1
- Sort by multiple columns using get_posts