Sorting: custom query with orderby meta_value_num THEN by title

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);

deneme bonusu veren sitelerbahis casinomakrobetceltabetpinbahispolobetpolobet girişpinbahis girişmakrobet girişpulibet girişmobilbahis girişkolaybet giriş