order by pre get posts

Solutions on MaxInterview for order by pre get posts by the best coders in the world

showing results for - "order by pre get posts"
Henry
14 Nov 2016
1add_action( 'pre_get_posts', 'standout_sort' );
2function standout_sort( $query ) {
3    if ( $query->is_main_query() && !is_admin() && is_post_type_archive('team') ) {
4        $query->set('orderby', 'meta_value_num');  
5            $query->set('meta_key', 'sort_order');  
6            $query->set('order', 'ASC'); 
7    }
8} 
similar questions
queries leading to this page
order by pre get posts