Take a look at the WordPress Codex:
http://codex.wordpress.org/Plugin_API/Filter_Reference/posts_orderby
function edit_posts_orderby($orderby_statement) {
$orderby_statement = "meta_value DESC";
return $orderby_statement;
} add_filter('posts_orderby', 'edit_posts_orderby');
If you’re making the WP_Query yourself you can change the orderby
parameter to meta_value
Take a look here:
http://codex.wordpress.org/Class_Reference/WP_Query
Related Posts:
- wordpress query – orderby child post date
- Query by one meta_key and sort by another (possibly NULL value)
- Filter query posts by the count of metas for a meta key
- can’t get query to order posts by acf datepicker
- mySQL query. ORDER BY meta_key
- Change media attachment author via mysql query
- Order posts by custom field DATE value
- Ordering by a metadata subfield in WordPress?
- Different values for get_author_posts_url and get_the_author (posts 2 posts)
- List author’s posts with SQL
- Order by title – but now built in wordpress func, sort the_title
- Querying with WP query using meta key price
- How to manage a particular “order by” for get_search_query()?
- Order terms by count – missing terms
- JetEngine Query Builder – order by value from repeater
- Order posts ascending from posts in array
- wp query multiple values > display a specific value first
- Order WordPress Query by Custom Field While Still Using Tax_query Argument
- “order” does not affect order of custom query
- Query Posts that have or don’t have a meta_value and order by the same ASC
- Apply ordering args to newly merged queried
- Query unique author ids with published post of type job
- WP_Query orderby meta key/value suddely stopped working
- Query parsing only author ids
- Query filter on custom post by current author in post widget for elementor query id
- Ascending & descending posts on same page with IF statement
- Get Terms by IDs with IDs order
- How many WordPress SQL Queries per page?
- Slow wp_enqueue_media()
- Advanced Custom Fields – Query Efficiency
- Show only oldest post by author
- How to display lastest post date in the homepage?
- How to tell if $query_var isset?
- Sorting Grids with Essential Grid and Events Manger
- The use of including upgrade.php when building custom queries
- Get the timout value of a saved transient?
- Does meta_query work within get_posts array?
- Slow meta_query with about 4 milion record on wp_postmeta
- How to show more than 5 posts?
- WordPress Find Duplicate Post By Content
- WP Query Sort by meta value (date)
- how to query multiple categories in wordpress?
- Disable the MySQL query in the main query
- Update slug (URL) of pending posts via phpMyAdmin
- How can I get the query that would be run for the archive page?
- Query metas (and not : query posts by metas)
- Select query for a login
- What’s wrong with my $wpdb prepare?
- Getting post data from private page
- Missing posts in a query
- Alter a specific query on WordPress
- SQL query to select posts from multiple categories
- Protect sequence of pages with same password for each of two groups of users
- How is it possible to get top comment from all children?
- Select Query demand excesive resources [closed]
- Create Indexes for Slow Queries
- Query to get number of posts last week
- I want to create a filter for the query string is this possible?
- Exclude categories from the_category();
- How can i show all categories using wp query?
- All in One Calendar Plugin Custom Post Type Query [closed]
- Get Posts from Last 24 hours and Sort them via GD Star Rating
- Query returning same results even though the ID changes
- Why my query ‘REPLACE INTO…’ does not work?
- Restrict query to last day with posts
- Custom query object with Simple-Fields custom date field
- How to read the value of a WordPress $query associative array (hash) key
- Query posts based on previous query
- Waypoints + infinite scroll with custom query
- Customizing the_tags output?
- Display a list of all post from the Author in the author’s page (author.php) in alphebetical order
- Re-sort get_posts query results
- How do I get all results from my query
- Taxonomy filter under Polylang
- How to create an overview of posts with the same tag?
- Adjust the order for returned posts
- create a link to a random post within the current category
- Pagination not working on custom post types with rewrite slug
- Change pure SQL database query to WordPress post query?
- Filter orders by modify date
- Heavy meta query causing SQL crash
- Custom post type order by post_title
- Sort by postmeta on when searching
- Pulling an ACF into a query
- Speed up search query that searches in post meta?
- How to make a parent page for author.php?
- Using cron for multiple queries
- very slow wordpress query with default query
- Filter posts by author selected in page
- Custom Query problem access the values
- Set posts per page for parent category and it’s all children
- Exclude sticky posts from query
- Posts 2 Posts: query connected — orderby problem
- Rewrite Query_Var URL Parameter with Slug
- How to query different categories on index?
- How to specify what kind of is_single post?
- Can’t See Media Queries with Inspect Tool [closed]
- Print data from wordpress sql query
- Can I create my own query in wordpress with traditional methods?
- Querying Posts from ACF Repeater Subfield Select Value