Use a meta_query
and set type
to NUMERIC
–
$query->set('meta_query', array(
array(
'key' => '_ai_price_int',
'value' => array(0, 4000),
'compare' => 'BETWEEN',
'type' => 'NUMERIC'
)
));
$query->set('meta_key', '_ai_price_int');
$query->set('orderby', 'meta_value_num');
Related Posts:
- Order resultset by configured value and then list all the rest
- Why does this incorrect pre_get_posts meta_query work for sort order?
- Admin products page column not sorting
- Using meta_query on pre_get_posts to exclude a particular meta_key value
- Meta query interfering with orderby relevance
- Multiple Values stored as array in Meta Query
- Order by nested named meta queries with ‘exists’ and ‘not exists’
- Help With issue on pre_get_posts filter in taxonomy
- Arrange Posts By Date In Order Of Closest To The Current Date
- Using get_terms() with meta_query parameters
- pre_get_posts order by not working
- Does meta_query working with value paramater higher then 999?
- WP_Query ordered by meta_value_num doesn’t fetch posts without this meta field
- Custom post type archive with rand and meta_value
- How to orderby multiple meta fields if some fields are empty
- Help ordering Post loop by two meta values
- Order ascending is ignored in meta query?
- pre_get_posts and set
- Orderby doesn’t work like expected on custom query
- last_name + first_name orderby with meta_query [solved]
- Can I use pre_get_posts to add up values from two different meta_keys?
- Fetch custom post related to a User
- How to Ordering by user meta
- meta_query Array
- Sort products by Sale price and stock status
- Querying terms with calculations based on term meta data, sql vs. get_terms
- meta_query check multiple date formats
- WordPress meta query not working
- Get meta_value from GDRating
- WordPress meta query with meta serialized data array value
- Reading Content in an Array as it relates to a meta_query
- How to output meta_key in wp_postmeta?
- Meta query array – same order as specified order in value
- How can meta values from another site in a multisite be used in a custom query?
- How to order product for key exists?
- Sort on meta value but include posts that don’t have one
- How to do a meta query using REST-API in WordPress 4.7+?
- WP_Query orderby post__in remains ineffective in the Loop [closed]
- How to Change Order of Posts in Admin?
- Meta query terribly slow
- multiple orderby in pre_get_posts action
- ORDER BY custom field value
- Sorting: custom query with orderby meta_value_num THEN by title
- meta_query sorting by 2 keys
- Get result from meta_query() between two numbers
- How to handle optional end date in compare clause in meta_query
- SELECT max(meta_value) FROM wp_postmeta WHERE meta_key=’price’… stops working when value is over 999
- Changing the meta_query of the main query based on custom query_vars and using pre_get_posts
- Sort Order for a Custom Query in a Post Type Archive Not Working
- Is it possible to orderby multiple meta_keys when using meta_value_num?
- Custom WP_Query order by post_meta and (author) user_meta
- Query between two meta keys
- Ordering posts having multiple post-meta date fields
- Archives for custom post type based on a “date” meta value
- How to check a single number value against an array of meta_key values?
- get_users meta_query
- Meta query with multiple logic (AND / OR)
- Order Posts by Taxonomy and Meta Value
- Best practice – Meta Query vs. post_clauses for “left join” ordering
- meta_query with multiple values
- WP REST API: Order posts by meta value (acf)?
- Different page parameters inside query
- Trying to perform complex custom field query with order by set to field value
- Return posts with specific meta key first, but the rest in alpha order by last name
- meta_query key value from array
- Is there a way to do multiple ordering on a multiple meta_query?
- filter search result with custom post type meta key
- LIKE %…% Meta Query
- Order posts by (hierarchical custom) taxonomy terms and term children
- How to alter query order direction using $query->set(‘order’, ‘ASC’); inside a pre_get_posts filter?
- Meta Query “IN” doesn’t work with ACF checkbox filter
- Order by custom field date with ASC order
- Documentation for post meta
- How to order a post type with meta_value_num and if meta_value_num does not exist then order by date
- Advanced orderby with multiple meta_query
- WP_User_Query with meta_query array relation ‘OR’
- Ordering posts by anniversary using only day and month
- Can’t sort order of wp_query with 2 meta keys
- Sort custom post types by last name in the backend
- query order by date on custom type: wrong order
- pre_get_posts filter using numeric meta_query comparison (from dates)
- Filter query posts by the count of metas for a meta key
- meta_query problem
- Custom Upcoming Events List for Events Manager Plugin
- Very slow query with meta_query on large database
- How to use meta_query to check if a meta field has something set?
- Using meta_query and custom fields within pre_get_posts to return posts within a numerical range
- Comparing arrays with meta_query in pre_get_posts
- pre_get_posts and search query for admin
- Ordering by meta_value AND date NOT WORKING with wp_query
- Using database meta_values to calculate new post order using pre_get_posts or a ‘request’ hook
- How to exlude posts that have certain meta_value?
- Order WP Query posts by custom order calculated from post meta values
- Display custom post types with custom date field value (before today) & order by custom date field
- User Relationship
- Sorting posts by multiple values, combined
- Order by meta_key with two meta_queries
- meta_query results not the same with and without spaces
- Meta query with order by another custom field
- meta_query all posts between to ages