First of all, never ever use query_posts
. It breaks the main function and all plugins and functions relying on the main query object. For custom queries, use WP_Query
or get_posts
if aren’t looking to paginate the query
As for the following line
'orderby' => 'rr_recommends_count',
I can tell you that rr_recommends_count
is an invalid value to the orderby
parameter. Suspect that this is actually the key name, and the values are all numerical in that key, so you would use the meta_value_num
value to the orderby
parameter which is a valid value
'orderby' => 'meta_value_num',
Please see Order and Orderby Parameters in WP_Query
Related Posts:
- Order by nested named meta queries with ‘exists’ and ‘not exists’
- Arrange Posts By Date In Order Of Closest To The Current Date
- WP_Query ordered by meta_value_num doesn’t fetch posts without this meta field
- Custom post type archive with rand and meta_value
- WordPress Screwing Up ‘orderby’ => ‘meta_value_num’ in ‘pre_get_posts’
- last_name + first_name orderby with meta_query [solved]
- Order resultset by configured value and then list all the rest
- meta_query check multiple date formats
- Why does this incorrect pre_get_posts meta_query work for sort order?
- Meta query terribly slow
- meta_query sorting by 2 keys
- How to handle optional end date in compare clause in meta_query
- Using meta_query on pre_get_posts to exclude a particular meta_key value
- How to check a single number value against an array of meta_key values?
- Meta query with multiple logic (AND / OR)
- Best practice – Meta Query vs. post_clauses for “left join” ordering
- Different page parameters inside query
- Is there a way to do multiple ordering on a multiple meta_query?
- LIKE %…% Meta Query
- Multiple Values stored as array in Meta Query
- Documentation for post meta
- Ordering posts by anniversary using only day and month
- 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?
- Display custom post types with custom date field value (before today) & order by custom date field
- How to make a WP REST API query with meta_query in WP4.7?
- Order Posts by meta value AND published date
- Nested Queries using meta_query
- Use both meta query and tax query
- Query posts only if meta_value is not empty
- Complex Orderby Parameters: How to query with multiple orderby parameters using meta_value_num?
- pre_get_posts order by not working
- Display post in order of ACF checkbox?
- How to pass user meta_key and meta_value (values as array)
- Query Multiple values for same key
- Comparing a field with several values at once with meta_query
- Meta query with a sub query group possible?
- meta_query compare=’!=’ with multiple custom fields
- Query posts with numeric meta values within a given range
- meta_query not working on live site
- How do you get Posts by multiple meta_keys and meta_values with the Rest API V2?
- Query custom field with date
- Meta query with regular expression does not work
- Searching in title or meta, with a tax query too!
- Help ordering Post loop by two meta values
- meta_value_num not ordering all items
- Ordering custom post type by multiple custom fields
- Change order of posts
- Pre Get Posts / Multiple Meta Keys / Orderby Single Key
- Help on multiple meta_query
- Meta query – How to display a null meta key
- pre_get_posts and set
- How to query wp_postmeta table for any specific meta_value?
- User meta query results in PHP notice: only variables should be passed by reference
- meta_query with multiple values optimization
- Get a single post ID based on an exact match of 1 or more meta values
- meta_query with multiple key
- ORDER BY custom field value out of where clause
- Extend meta query arguments
- get_posts( $args ) return empty data
- WP_Query of custom post type sorted by meta_key has unexpected results
- how to get post meta where value is an array of key value pairs
- Meta Query Based on Month Range
- how to search all user meta data that have value like “vivek”
- wordpress meta value compare between two date
- WP JSON API meta_query not working
- Ordering custom posts by meta field date
- Sort posts using multiple custom fields and menu_order in single query?
- How to properly escape values in meta query
- Fetch custom post related to a User
- How to Ordering by user meta
- Use meta_query in args for relationship
- meta_query compare “=“ returns nothing when it seems it should
- Querying terms with calculations based on term meta data, sql vs. get_terms
- get_user can’t read variable
- WordPress Query custom ordering by temporary variable
- WP_User_Query Orderby Not Working
- WordPress meta query not working
- Get meta_value from GDRating
- meta_query orderby sort multiple keys
- Meta_Query with multi select values
- How to sort custom posts including null meta-values in admin columns with meta_query?
- Get Posts from Custom Meta Query
- get posts meta query returning the latest post if no meta key found
- Search using specific meta fields only (excluding post title and content)
- Best way to Order Post in Home without a plugin
- How to fetch WP_User_Query with multiple role arguments [duplicate]
- How to get meta value based on latest post id with group by term name
- Meta query not returning results even though the sql contains the information
- Display Users from two roles in one list
- shortcode order for event custom post type
- Multiple Queries with meta_query
- Get foreach for meta_query value
- Sorting: custom query with orderby meta_value_num THEN by title
- order by meta_key [duplicate]
- Order Wp Query by earliest of 3 dates meta query
- Meta query with string NOT ending like pattern
- acf/save_post affecting WP_Query results
- Merge meta_value’s into a single row and then loop