This is very crude but should sort your posts by year (meta_value) and then by title. It does depend on how the query is setup so it will only work with the query below or with similar ones.
function alter_order_wpse_103181($order,$qry) {
remove_filter('posts_orderby','alter_order',1,2);
$order = explode(',',$order);
$order = implode( ' ASC,',$order);
return $order;
}
add_filter('posts_orderby','alter_order_wpse_103181',1,2);
$q = new WP_Query();
$q->query( array(
'post_type' => 'movies',
'distribution' => 'companyA',
'meta_key' => 'year',
'orderby' => 'meta_value_num title',
'order' => 'ASC',
'posts_per_page' => -1,
'post_status' => 'publish',
));
var_dump($q->request);
Related Posts:
- Meta query with order by another custom field
- Help ordering Post loop by two meta values
- Sorting: custom query with orderby meta_value_num THEN by title
- Ignoring initial articles (like ‘a’, ‘an’ or ‘the’) when sorting queries?
- How to get order of posts?
- Custom WP_Query order by post_meta and (author) user_meta
- How to order a post type with meta_value_num and if meta_value_num does not exist then order by date
- Order WP Query posts by custom order calculated from post meta values
- Order Posts by meta value AND published date
- How to orderby meta_value_num with dollar ($) sign
- How do I sort posts with multiple pages
- Complex Orderby Parameters: How to query with multiple orderby parameters using meta_value_num?
- pre_get_posts order by not working
- SQL: What is wrong with the following query (generated by WordPress WP_Query, ordering prices)
- How to orderby multiple meta fields if some fields are empty
- Sort wordpress custom posts based on meta value
- WP_Query: Group events by year, sorted DESC; then by date for each year group, sorted ASC
- Understanding the orderby in WP_Query?
- Order ascending is ignored in meta query?
- meta_value_num not ordering all items
- How to filter a query by multiple meta keys and order by other meta keys
- Advanced WP_Query with meta_query, orderby?
- Sorting search results with custom dropdown
- orderby ignored by wp_query
- Sort posts using multiple custom fields and menu_order in single query?
- What’s wrong with this meta query? (order by meta key, then title, doesn’t work)
- Order (by ASC) posts with meta_key so posts without values are last
- How to sort store location by specific category order in WP store locations
- How to sort wordpress posts already selected by WP_QUERY
- WordPress Query custom ordering by temporary variable
- Meta query orderby meta_value_num sorting by role first
- WP_User_Query Orderby Not Working
- Order by value of Custom Field using url string
- WP Query with meta queries
- Order 2 meta_queries differently in WP_Query?
- Sorting with meta_query and multiple, optional meta keys
- WP Query. Ordering posts by another post types meta
- wp_query sorting – one specific meta_key value at last and then sort by create date
- Display three sequential posts on each page load, without repeating previous
- Best way to Order Post in Home without a plugin
- Using orderby with 2 meta keys
- query_posts with sorting on a custom datestamp
- Sort Posts with custom meta key by default which is currently set as optional
- WP_Query with several meta_query-statements and order by meta_value
- Meta_query compare operator explanation
- meta_query ‘compare’ => ‘IN’ not working
- ORDER BY custom field value
- Sorting posts by custom date fields (non standard date format)
- Query Multiple Post types each with own meta query
- Is “orderby” in WP Meta Query conflicting with Meta Query?
- WP Meta Query for some meta (array) values
- Sort users by meta_value_num
- meta_query with array as value
- Sort in WP_Query(), not filter? Is it possible?
- Front End Sorting Questions
- Using WP Query to search within ALL keys in meta query
- WP Query – Get WooCommerce Products with variation that is in stock
- Meta_query with or without value
- Custom Post order for homepage
- Sorting posts DESC based on the number of comments using WP_Query
- wp_query not searching with apostrophe
- Custom query based on meta key – Reduce three states to two in results?
- Performance when getting post meta for post retrieved by meta value
- How to display multiple custom fields with the same meta_key in an ascending order?
- Meta_query with multiple keys and multiple values
- Order by empty custom field
- Tax query AND/OR meta query [duplicate]
- How to sort a custom wordpress query by combination of meta values?
- Ordering posts by an array
- I am having problem sorting custom post type using WP_Query
- Is this meta query problematic?
- Get meta_value of a specific meta_key from all posts belonging to a specific custom type
- Custom query filter by ACF date custom field
- Nested array issue in meta_query
- Child pages not affected by orderby
- Error in meta_query not get result
- Sorting posts by Multiple custom fields in defined order
- How to get current page nearest parent id?
- meta_query with array as value with multiple arrays
- Why doesn’t my WP Meta Query return any results?
- How to order query results based on if a custom field has been populated, then the order by the date of the post?
- meta_query – check for multiple meta values in key which holds an array of values
- Custom WP Query order function possible?
- How sort products by calculate value? ( custom post meta, price, option)
- Searching for a specific month in a metadata saved as Timestamp (Wp_Query)
- Order Element By Custom Field in WordPress
- WP_Query on custom key and value
- Get posts having meta value between two numbers
- Wp Query sort order from custom MetaBox
- Case insensitive ORDERBY in wpquery
- How to mix two orderby-parameters into one ordered result
- Query by meta value (add a dropdown of all values)
- Combine WP_Query with array of custom data to single loop without breaking the pagination
- WordPress meta_query not working
- Passing conditional arrays to WP_Query() [closed]
- wordpress sorting using array merge by price in ascending order but price with 0 must be show last
- Get all user with both meta_value
- Using ‘meta_query’ with the ‘pre_get_posts()’ hook disables searching for post titles
- Get posts using multiple values from ACF checkbox as meta query wordpress
- WP Query returning all posts when Meta_query is null