orderby複数指定

http://chaika.hatenablog.com/entry/2015/12/25/154244
http://chaika.hatenablog.com/entry/2015/06/05/120000
http://chaika.hatenablog.com/entry/2015/12/25/154244

orderby複数指定

geto post
結果

 <?php
    $args = array(
        'posts_per_page' => 9,
        'post_type' => 'cast', //カスタム投稿名
		'orderby' => array('menu_order'=> 'DESC','date'=> 'DESC'),
);
 
    $myposts = get_posts( $args );
    foreach ( $myposts as $post ) : setup_postdata( $post ); ?>
    
<?php include( get_stylesheet_directory() . '/roop/cast_roop_box.php'); ?>







  <?php endforeach; 
wp_reset_postdata();?>
   
//function.php
function change_posts_query( $query ) {
  if( is_archive() ) {
    $query->set('meta_key', 'release_time');
    // orderby に orderby => order 形式の配列で条件と並び順を渡してあげればOK
    $query->set('orderby', array('meta_value_num' => 'ASC', 'date' => 'DESC') );
    // order は不要
    // $query->set('order', 'DESC');
  }
}
add_action('pre_get_posts', 'change_posts_query');