Sorting a custom post type in pre_get_posts

You can add a filter on posts_clauses to; left join additional columns for each meta filter add order by clause base on those column values. Something like below should work, assuming your meta key is start_date and the value has the actual date format Y-m-d and your post type is talks add_filter( ‘posts_clauses’, function ($clauses, … Read more

User Query Multiple Orderby Clause

Try using: ‘orderby’=>’distribution_list last_name’, ‘order’=>’ASC’ Instead of: ‘orderby’ => array( ‘distribution_list’ => ‘ASC’, ‘last_name’ => ‘ASC’, ), So: $users = new WP_User_Query( array( ‘meta_query’ => array( ‘relation’ => ‘AND’, ‘lastname’ => array( ‘key’ => ‘last_name’, ‘compare’ => ‘EXISTS’, ‘type’ => ‘CHAR’, ), ‘list’ => array( ‘distribution_list’ => array( ‘key’ => ‘distribution_list’, ‘value’ => ‘”72″‘, ‘compare’ … Read more